Custom
public final class Custom<T, R> : RestEndpoint where T : CorvusModel, R : ResponseEncodable
A class that contains custom functionality passed in by the implementor for
a generic type T
conforming to CorvusModel
grouped under a given
path.
-
Declaration
Swift
public typealias Element = R
-
Declaration
Swift
public typealias QuerySubject = T
-
The path to the component, can be used for route parameters.
Declaration
Swift
public let pathComponents: [PathComponent]
-
The HTTP method of the
Custom
operation.Declaration
Swift
public let operationType: OperationType
-
Initializes the component with path information, operation type of its functionality and a custom handler function passed in as a closure.
Declaration
Swift
public init( pathComponents: PathComponent..., type operationType: OperationType, _ customHandler: @escaping (Request) throws -> EventLoopFuture<Element> )
Parameters
pathComponents
One or more objects describing the route.
operationType
The type of HTTP method the handler is used for.
customHandler
A closure that implements the functionality for the
Custom
component. -
A method to return an element of type
R
return by the custom handler.Throws
AnAbort
error if something goes wrong.Declaration
Swift
public func handler(_ req: Request) throws -> EventLoopFuture<Element>
Parameters
req
An incoming
Request
.Return Value
An element of type
R
.