Download the PHP package benycode/slim-middleware without Composer
On this page you can find all versions of the php package benycode/slim-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download benycode/slim-middleware
More information about benycode/slim-middleware
Files in benycode/slim-middleware
Informations about the package slim-middleware
Slim Middleware bundle
A Slim 4 Framework useful middlewares.
Features
- health check endpoint;
- info endpoint;
- settings setup;
- exception handler;
- APISIX auto route register;
- Leader election middleware;
- Endpoint protection with X-Api-Token.
Table of contents
- Install
- [Health check endpoint usage](#health check endpoint usage)
- [Info endpoint usage](#info endpoint usage)
- [Settings setup usage](#settings setup usage)
- [Exception handler usage](#exception handler usage)
- [APISIX auto route register usage](#apisix auto route register usage)
- [Leader election usage](#leader election usage)
- [Endpoint protection with X-Api-Token usage](#endpoint protection with X-Api-Token usage)
Install
Via Composer
Requires Slim 4.
Health check endpoint usage
Use DI to inject the library Middleware classes:
add the Middleware to any
route at the end of the routes:
welcome, your app is within new path:
- /_health or your defined
create health check.
Info endpoint usage
Use DI to inject the library Middleware classes:
add the Middleware to any
route at the end of the routes:
welcome, your app is within new path:
- /_info
Settings setup usage
add the Middleware to a global
list:
get the settings:
Exception handler usage
add the Middleware to a global
list:
welcome, your app is within new error handler.
APISIX auto route register usage
Idea: Auto create service and routes on the health check procedure.
You can use it with:
- Docker health check;
- k8s health check;
- and more others....
Requires curl
and docker/k8s
health check mechanism.
Balanced with LeaderElectionMiddleware
, bring more stability and activate one instance registration functionality.
Use DI to inject the library Middleware classes:
add the Middleware to any
route at the end of the routes:
create health check /_health
or your defined.
welcome, your app will be auto (re)registered in the APISIX on the every health check.
Leader election usage
Idea: in the microservice world can be more then one instance who can execute the relevant commands and there is a need for those commands to be executed only by one. Vote for the leader using health check mechanizm!
Balanced with the APISIXRegisterMiddleware
.
You can use it with:
- Docker health check;
- k8s health check;
- and more others....
Requires curl
, docker/k8s
health check mechanism and ETCD v3
.
Use DI to inject the library Middleware classes:
add the Middleware to any
route at the end of the routes:
get the leader status:
Endpoint protection with X-Api-Token usage
Idea: Protect you endpoints like health check with Api token.
Use DI to inject the library Middleware classes:
add the Middleware to any
route at the end of the routes: