BasicResponder

public struct BasicResponder : Responder

A basic, closure-based Responder.

  • Create a new BasicResponder.

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

    Declaration

    Swift

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

    Parameters

    closure

    Responder closure.

  • See Responder.

    Declaration

    Swift

    public func respond(to req: Request) throws -> Future<Response>