Adds Application.Responder
helper for configuring which Responder
the application will use. This works similarly to Application.Sessions
(fixes #2181, #2185).
The application can be configured to use the default responder or a custom one.
app.responder.use(.default)
app.responder.use(.foo)
// or
app.responder.use { app in
FooResponder(routes: app.routes)
}
Leading dot-syntax can be achieved by extending Application.Responder.Provider
.
Vapor exposes .default
and app.responder.default
which return a DefaultResponder
.
To create a responder, use current
:
app.responder.current.respond(to: ...)
Application.Responder
conforms to Responder
for backward compatibility. This creates a new instance of the responder for each call, so storing app.responder.current
should be used where performance is important.
app.responder.respond(to: ...)