mirror of https://github.com/vapor/docs.git
22 lines
528 B
Markdown
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
|
|
}
|
|
}
|
|
```
|