vapor-docs/3.0/docs/http/responder.md

22 lines
528 B
Markdown

# Responder
Responders are a type capable of [responding](response.md) to a [Request](request.md).
Responders are always [async](../async/futures.md) by returning a `Future<Response>` by either transforming/mapping an existing future or creating it's own promise.
## Implementing a static Responder
```swift
struct StaticResponder: Responder {
let response: Response
init(response: Response) {
self.response = response
}
func respond(to req: Request) throws -> Future<Response> {
return response
}
}
```