Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jan 12, 2019
1 parent 16b677b commit 06e0095
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/classes/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A default implementation can be found in `Amp\Http\Server\Driver\RemoteClient`.
* Table of Contents
{:toc}

## `start(HttpDriverFactory)`
## `start(HttpDriverFactory $factory)`

Listen for requests on the client and parse them using the given HTTP driver.

Expand Down Expand Up @@ -71,7 +71,7 @@ Otherwise returns an empty array.

Integer mask of `Client::CLOSED_*` constants.

## `onClose(callable)`
## `onClose(callable $onClose)`

Attaches a callback invoked with this client closes.
The callback is passed this object as the first parameter.
Expand Down
12 changes: 6 additions & 6 deletions docs/classes/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Classes have to implement the `Middleware` interface for that.
> Middleware generally follows other words like soft- and hardware with its plural.
> However, we use the term _middlewares_ to refer to multiple objects implementing the `Middleware` interface.
## `handleRequest(): Promise`
## `handleRequest(Request $request, RequestHandler $next): Promise`

`handleRequest(Request, RequestHandler): Promise` is the only method of the `Middleware` interface.
If the `Middleware` doesn't handle the request itself, it should delegate the response creation to the received `RequestHandler`.
If the `Middleware` doesn't handle the request itself, it should delegate the response creation to the received `RequestHandler`. The promise returned from this method should resolve to an instance of `Response`.

## `stack()`
## `stack(RequestHandler $handler, Middleware ...$middlewares): RequestHandler`

Multiple middlewares can be stacked by using `Amp\Http\Server\Middleware\stack()`, which accepts a `RequestHandler` as first argument and a variable number of `Middleware` instances.

Expand All @@ -39,13 +39,13 @@ $middleware = new class implements Middleware {
return call(function () {
$requestTime = microtime(true);

$response = $next->handleRequest($request);
$response = yield $next->handleRequest($request);
$response->setHeader("x-request-time", microtime(true) - $requestTime);

return $response;
return $response;
});
}
};

$server = new Server($servers, Middleware\stack($handler, $middleware));
$server = new Server($servers, Middleware\stack($handler, $middleware), $logger);
```
2 changes: 1 addition & 1 deletion docs/classes/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Returns the maximum number of connections that can be handled by the server at a
{:.note}
> Default connection limit is `10000`.
## `withConnectionLimit(): Options`
## `withConnectionLimit(int $limit): Options`

Sets the maximum number of connections the server should accept at one time. If that number is exceeded, new connections are dropped.

Expand Down
2 changes: 1 addition & 1 deletion docs/classes/request-body.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
|`callable`<br>`null`|`$upgradeSize`|Callback used to increase the maximum size of the body.|
|`Promise`<br>`null`|`$trailers`|Promise for trailing headers.|

## `increaseSizeLimit(int)`
## `increaseSizeLimit(int $limit)`

Increases the size limit dynamically if an `$upgradeSize` callback is present.
Otherwise this is a no-op.
Expand Down

0 comments on commit 06e0095

Please sign in to comment.