HBRequestDecodable
public protocol HBRequestDecodable : HBRouteHandler, Decodable
HBRouteHandler
which uses Codable
to initialize it
An example
struct CreateUser: HBRequestDecodable {
let username: String
let password: String
func handle(request: HBRequest) -> EventLoopFuture<HTTPResponseStatus> {
return addUserToDatabase(
name: self.username,
password: self.password
).map { _ in .ok }
}
application.router.put("user", use: CreateUser.self)
-
init(from:)
Extension methodCreate using
Codable
interfacesThrows
HBHTTPErrorDeclaration
Swift
public init(from request: HBRequest) throws
Parameters
request
request