Create Custom Middleware
Basic Handler
class TimingHandler < Azu::Handler::Base
def call(context)
start = Time.instant
call_next(context)
duration = Time.instant - start
context.response.headers["X-Response-Time"] = "#{duration.total_milliseconds.round(2)}ms"
end
endRegister the Handler
MyApp.start [
TimingHandler.new, # First in chain
Azu::Handler::Rescuer.new,
Azu::Handler::Logger.new,
# ... endpoints
]Authentication Handler
CORS Handler
Rate Limiting Handler
Request ID Handler
Compression Handler
Conditional Handler
Handler Ordering
See Also
Last updated
Was this helpful?
