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

528 B

Responder

Responders are a type capable of responding to a Request.

Responders are always async by returning a Future<Response> by either transforming/mapping an existing future or creating it's own promise.

Implementing a static Responder

struct StaticResponder: Responder {
  let response: Response

  init(response: Response) {
    self.response = response
  }

  func respond(to req: Request) throws -> Future<Response> {
    return response
  }
}