From ed91fcc8e3166d281e454d60b982bbaab8bb40cf Mon Sep 17 00:00:00 2001 From: AMPHP Bot Date: Mon, 27 Nov 2023 10:55:12 +0100 Subject: [PATCH] Sync http-server-static-content.md --- http-server-static-content.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/http-server-static-content.md b/http-server-static-content.md index 8b526e2..4f16f5e 100644 --- a/http-server-static-content.md +++ b/http-server-static-content.md @@ -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!'); })); @@ -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.