Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mnavarrocarter/amp-http-router

An asynchronous HTTP routing engine for Amp based applications
https://github.com/mnavarrocarter/amp-http-router

amphp amphp-http express http middleware router

Last synced: about 1 month ago
JSON representation

An asynchronous HTTP routing engine for Amp based applications

Awesome Lists containing this project

README

        

AMP HTTP Router
===============

A high performance routing engine that handles requests for an Amp HTTP Server inspired in
Express JS.

## Installation

```bash
composer require mnavarrocarter/amp-http-router
```

## Quick Start

```php
getParam('id');
return html(sprintf('The user id is %s', $id));
}

$router = Router::create();
$router->get('/', handleFunc('homepage'));
$router->get('/users/:id', handleFunc('findUser'));

Amp\Loop::run(fn() => yield listenAndServe('0.0.0.0:8000', $router));
```

### Router Composition

You can have multiple routers mounted to different paths for more efficient
routing:

```php
mount('/api', $api);
```