abstract class Marten::Middleware
- Marten::Middleware
- Reference
- Object
Overview
Represents an abstract middleware.
A middleware is a simple class that implements a #call
method that can be hooked into Marten's request/response
lifecycle. Middlewares can be used to perform simple alterations based on the incoming HTTP request and the returned
HTTP response: for example they can be used to activate a specific I18n locale, to identify a currently logged in
user, etc.
Direct Known Subclasses
- Marten::Middleware::AssetServing
- Marten::Middleware::ContentSecurityPolicy
- Marten::Middleware::Flash
- Marten::Middleware::GZip
- Marten::Middleware::I18n
- Marten::Middleware::MethodOverride
- Marten::Middleware::ReferrerPolicy
- Marten::Middleware::Session
- Marten::Middleware::SSLRedirect
- Marten::Middleware::StrictTransportSecurity
- Marten::Middleware::XFrameOptions
Defined in:
marten/middleware.crmarten/middleware/asset_serving.cr
marten/middleware/content_security_policy.cr
marten/middleware/flash.cr
marten/middleware/gzip.cr
marten/middleware/i18n.cr
marten/middleware/method_override.cr
marten/middleware/referrer_policy.cr
marten/middleware/session.cr
marten/middleware/ssl_redirect.cr
marten/middleware/strict_transport_security.cr
marten/middleware/x_frame_options.cr
Instance Method Summary
-
#call(request : Marten::HTTP::Request, get_response : Proc(Marten::HTTP::Response)) : Marten::HTTP::Response
Calls the middleware for a given HTTP request and returns a HTTP response.
-
#next : Nil | Middleware
:nodoc
-
#next=(next __arg0 : Nil | Middleware)
:nodoc
Instance Method Detail
Calls the middleware for a given HTTP request and returns a HTTP response.
This method must be implemented by subclasses: it takes a request
argument (the current HTTP request) and a
get_response
proc that allows to get the final response. This proc might actually call the next middleware in
the chain of configured middlewares, or the final matched handler. That way, the current middleware have the
ability to intercept any incoming request and the associated response, and to modify them if applicable.