Download the PHP package barretstorck/server-request-router without Composer
On this page you can find all versions of the php package barretstorck/server-request-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download barretstorck/server-request-router
More information about barretstorck/server-request-router
Files in barretstorck/server-request-router
Download barretstorck/server-request-router
More information about barretstorck/server-request-router
Files in barretstorck/server-request-router
Vendor barretstorck
Package server-request-router
Short Description A PSR-15 compliant HTTP middleware that routes requests to other middlewares
License MIT
Package server-request-router
Short Description A PSR-15 compliant HTTP middleware that routes requests to other middlewares
License MIT
Please rate this library. Is it a good library?
Informations about the package server-request-router
Server Request Router
A PSR-15 compliant ServerRequestInterface router that allows for conditional routing to different middlewares based on the properties of the ServerRequest. This allows for only using middlewares when they are needed, and when the middlewares are provided as lazy objects then they can skip instantiation entirely if not needed, saving time and server resources.
Installation
Examples
Hello world
Echo value from URL path
Larger example with API endpoints
Includes:
- Middlewares that are performed for all requests
- ErrorCatcherMiddleware
- MessageLoggerMiddleware
- RateLimiterMiddleware
- A branch to handle when the request has contents in the body
- Return a 413 "Content Too Large" response if the body is too big
- Otherwise pass the request to an AntiMalwareMiddleware
- A branch to handle the "/comments" API endpoint
- GET method calls CommentsGetMiddleware
- PUT method calls CommentsPutMiddleware
- POST method extracts the comment ID from the URL path, sets it as an attribute on the Request, and calls CommentsPostMiddleware
- DELETE method calls CommentsDeleteMiddleware
- A default response of 404 "Not Found" for all other requests
The code above provides a Router that matches the following flow chart:
All versions of server-request-router with dependencies
PHP Build Version
Package Version
Requires
psr/http-message Version
^1.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
The package barretstorck/server-request-router contains the following files
Loading the files please wait ...