Instance Method
encodeResponse(status:headers:for:)
Asynchronously encodes
Self into a Response, setting the supplied status and headers.func encodeResponse(status: HTTPStatus, headers: HTTPHeaders = [:], for request: Request) -> EventLoopFuture<Response>
Parameters
statusHTTPStatusto set on theResponse.headersHTTPHeadersto merge into theResponse’s headers.
Return Value
Newly encoded Response.
Discussion
router.post("users") { req -> EventLoopFuture<Response> in
return try req.content
.decode(User.self)
.save(on: req)
.encode(status: .created, for: req)
}