Vapor Documentation Beta

Structure Basic​Responder

public struct BasicResponder: Responder

A basic, closure-based Responder.

%3 BasicResponder BasicResponder Responder Responder BasicResponder->Responder

Conforms To

Responder

Initializers

init(closure:​)

public init(closure: @escaping (Request) throws -> EventLoopFuture<Response>)

Create a new BasicResponder.

let notFound: Responder = BasicResponder { req in
    let res = req.response(http: .init(status: .notFound))
    return req.eventLoop.newSucceededFuture(result: res)
}

Parameters

closure @escaping (Request) throws -> Event​Loop​Future<Response>

Responder closure.

Methods

respond(to:​)

public func respond(to request: Request) -> EventLoopFuture<Response>

See Responder.