Skip to content
A static content responder for Amp's HTTP server.
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Add example Sep 14, 2018
resources Update font mime types Apr 15, 2018
src Add max-age attribute (#10) Jan 9, 2019
test
.gitattributes Initial commit after split from http-server Mar 12, 2018
.gitignore Initial commit after split from http-server Mar 12, 2018
.php_cs.dist Apply PSR-2 as code style Jun 19, 2018
.travis.yml Initial commit after split from http-server Mar 12, 2018
LICENSE
README.md Add README Sep 14, 2018
composer.json Allow amphp/http-server ^1 Dec 10, 2018
phpunit.xml.dist Initial commit after split from http-server Mar 12, 2018

README.md

http-server-static-content

This package provides a static content RequestHandler for Amp's HTTP server.

Usage

DocumentRoot implements RequestHandler.

Example

<?php

use Amp\Http\Server\RequestHandler\CallableRequestHandler;
use Amp\Http\Server\Response;
use Amp\Http\Server\Router;
use Amp\Http\Server\Server;
use Amp\Http\Server\StaticContent\DocumentRoot;
use Amp\Http\Status;

$documentRoot = new DocumentRoot(__DIR__ . '/public');

$router = new Amp\Http\Server\Router;

$router->addRoute('GET', '/', new CallableRequestHandler(function () {
    return new Response(Status::OK, ['content-type' => 'text/plain'], 'Hello, world!');
}));

$router->setFallback($documentRoot);

$server = new Server(..., $router, ...);
You can’t perform that action at this time.