Expand description
The middleware groups Rainier ships — Laravel’s web and api, as
functions rather than as keys in a map.
ⓘ
use rainier_framework::groups;
router.group(GroupAttributes::new().middleware(groups::web()), |router| {
router.get("/", home);
});Three things follow from a group being a function.
You can find it. “Go to definition” on groups::web() lands on the
list. Finding out what 'web' means in Laravel means grepping the kernel.
You cannot misspell it. groups::wev() does not compile. 'wev' boots
fine and serves every page in that group with no session and no security
headers.
Overriding is composition, not replacement. Laravel’s
$middlewareGroups['web'] = [...] replaces the whole list, which is how
people accidentally drop StartSession while adding one thing. Here an
application writes its own function and says what it is starting from:
ⓘ
pub fn web() -> MiddlewareStack {
rainier_framework::groups::web().with(RequestId::new())
}Functions§
- api
- CORS plus a rate limit — what a JSON API wants.
- api_
throttled apiwith an explicit per-minute limit.- normalise_
input - Normalise input — trim strings, and turn
""intonull. - session
- Start a session, using whichever store the application bound.
- trust_
local_ proxies - Trust
X-Forwarded-*from the loopback and the private ranges. - web
- Security headers plus a session — what a browser-facing page wants.