2017 © Pedro Peláez
 

library poa-static

Poa static file serving middleware.

image

york8/poa-static

Poa static file serving middleware.

  • Friday, February 23, 2018
  • by york8
  • Repository
  • 0 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

poa-static

Latest Version on Packagist ![Software License][ico-license] Total Downloads, (*1)

poa-static 是POA框架的一个中间件,用来处理静态文件的请求, (*2)

作者

安装

composer require york8/poa-static

使用

$app = new Application();

$staticMiddleware = new StaticMiddleware('..');
$staticMiddleware->use(new ProfileMiddleware())->use(new SimpleFilenamePlugin('/static'));

// 定义路由器,将路径 /static 前缀开头的请求交给 StaticMiddleware 处理
$router = new RouterMiddleware(function (Context $context) {
    $context->statusCode(404)->send('Not Found');
});
$router->get('/static', $staticMiddleware);

$app->useErrorMiddleware(function (Throwable $throwable) {
    // 全局未捕获 错误/异常 处理
    fwrite(STDERR, $throwable->getMessage() . "\n");
})
    // 简单请求错误异常处理
    ->use(function (Context $context) {
        try {
            yield;
        } catch (Throwable $exception) {
            fwrite(STDERR, $exception->getMessage() . "\n");
            $context->statusCode(500)->send($exception->getMessage());
        }
    })
    // 使用路由器
    ->use($router);

$app->listen('0.0.0.0:8088');

License

The MIT License (MIT). Please see License File for more information., (*3)

The Versions

23/02 2018

dev-master

9999999-dev

Poa static file serving middleware.

  Sources   Download

MIT

The Requires

 

by York

react-php koa poa poa-middleware koa-static

23/02 2018

0.1.0

0.1.0.0

Poa static file serving middleware.

  Sources   Download

MIT

The Requires

 

by York

react-php koa poa poa-middleware koa-static