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
Customoperation.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
pathComponentsOne or more objects describing the route.
operationTypeThe type of HTTP method the handler is used for.
customHandlerA closure that implements the functionality for the
Customcomponent. -
A method to return an element of type
Rreturn by the custom handler.Throws
AnAborterror if something goes wrong.Declaration
Swift
public func handler(_ req: Request) throws -> EventLoopFuture<Element>Parameters
reqAn incoming
Request.Return Value
An element of type
R.
Custom Class Reference