Skip to content

Commit

Permalink
Sync http-server-static-content.md
Browse files Browse the repository at this point in the history
  • Loading branch information
amphp-bot committed Nov 27, 2023
1 parent 1d5ea8b commit ed91fcc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion http-server-static-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ use Amp\Http\Server\StaticContent\DocumentRoot;
use Amp\Http\Status;

$router = new Amp\Http\Server\Router;
$router->setFallback(new DocumentRoot(__DIR__ . '/public'));
// $server is an instance of HttpServer and $errorHandler an instance of ErrorHandler
$router->setFallback(new DocumentRoot($server, $errorHandler, __DIR__ . '/public'));
$router->addRoute('GET', '/', new ClosureRequestHandler(function () {
return new Response(Status::OK, ['content-type' => 'text/plain'], 'Hello, world!');
}));
Expand All @@ -45,6 +46,8 @@ $router->addRoute('GET', '/', new ClosureRequestHandler(function () {
$server->start($router, new DefaultErrorHandler());
```

A full example is found in [`examples/server.php`](https://github.com/amphp/http-server-static-content/blob/2.x/examples/server.php).

## Contributing

Please read [our rules](https://amphp.org/contributing) for details on our code of conduct, and the process for submitting pull requests to us.
Expand Down

0 comments on commit ed91fcc

Please sign in to comment.