Middleware
[[toc]]
Introduction
Middleware can filtering HTTP requests that enter the application. For example, Goravel
provides a CORS middleware, which can implement requests across domains.
Define Middleware
You can create your own middleware in the app/http/middleware
directory, the structure is as follows.
There are some middleware available in Goravel:
Middleware
Action
github.com/goravel/framework/http/middleware/Cors
across domain
github.com/goravel/framework/http/middleware/Throttle
Rate Limiting
Create Middleware By Command
Register Middleware
Global Middleware
If you want to apply middleware for every HTTP request of your application, you only need to register the middleware in the Middleware
in the app/http/kernel.go
file.
Assign Middleware for Routing
You can register the middleware for some routing separately:
Last updated