-
An instance of
RouteCollection
.Declaration
Swift
public var routes: RouteCollection
-
Initializes a new instance with another
RouteCollection
.Declaration
Swift
public init(_ routes: RouteCollection = .init())
Parameters
routes
An instance of
RouteCollection
. -
Creates a new instance of
Route
with aDELETE
HTTP request method.Declaration
Swift
@discardableResult public func delete( _ path: String = Route.defaultPath, name: String = "", middleware: [Middleware] = .init(), handler: @escaping Route.Handler ) -> Route?
Parameters
path
A path to a resource. Defaults to
/
.name
A unique name for
Route
. Defaults to an empty string.middleware
An array of registered
Middleware
. Defaults to an empty array.handler
A handler to call.
Return Value
A new instance of
Route
. -
Creates a new instance of
Route
with aGET
HTTP request method.Declaration
Swift
@discardableResult public func get( _ path: String = Route.defaultPath, name: String = "", middleware: [Middleware] = .init(), handler: @escaping Route.Handler ) -> Route?
Parameters
path
A path to a resource. Defaults to
/
.name
A unique name for
Route
. Defaults to an empty string.middleware
An array of registered
Middleware
. Defaults to an empty array.handler
A handler to call.
Return Value
A new instance of
Route
. -
Creates a new instance of
Route
with aHEAD
HTTP request method.Declaration
Swift
@discardableResult public func head( _ path: String = Route.defaultPath, name: String = "", middleware: [Middleware] = .init(), handler: @escaping Route.Handler ) -> Route?
Parameters
path
A path to a resource. Defaults to
/
.name
A unique name for
Route
. Defaults to an empty string.middleware
An array of registered
Middleware
. Defaults to an empty array.handler
A handler to call.
Return Value
A new instance of
Route
. -
Creates a new instance of
Route
with aOPTIONS
HTTP request method.Declaration
Swift
@discardableResult public func options( _ path: String = Route.defaultPath, name: String = "", middleware: [Middleware] = .init(), handler: @escaping Route.Handler ) -> Route?
Parameters
path
A path to a resource. Defaults to
/
.name
A unique name for
Route
. Defaults to an empty string.middleware
An array of registered
Middleware
. Defaults to an empty array.handler
A handler to call.
Return Value
A new instance of
Route
. -
Creates a new instance of
Route
with aPATCH
HTTP request method.Declaration
Swift
@discardableResult public func patch( _ path: String = Route.defaultPath, name: String = "", middleware: [Middleware] = .init(), handler: @escaping Route.Handler ) -> Route?
Parameters
path
A path to a resource. Defaults to
/
.name
A unique name for
Route
. Defaults to an empty string.middleware
An array of registered
Middleware
. Defaults to an empty array.handler
A handler to call.
Return Value
A new instance of
Route
. -
Creates a new instance of
Route
with aPOST
HTTP request method.Declaration
Swift
@discardableResult public func post( _ path: String = Route.defaultPath, name: String = "", middleware: [Middleware] = .init(), handler: @escaping Route.Handler ) -> Route?
Parameters
path
A path to a resource. Defaults to
/
.name
A unique name for
Route
. Defaults to an empty string.middleware
An array of registered
Middleware
. Defaults to an empty array.handler
A handler to call.
Return Value
A new instance of
Route
. -
Creates a new instance of
Route
with aPUT
HTTP request method.Declaration
Swift
@discardableResult public func put( _ path: String = Route.defaultPath, name: String = "", middleware: [Middleware] = .init(), handler: @escaping Route.Handler ) -> Route?
Parameters
path
A path to a resource. Defaults to
/
.name
A unique name for
Route
. Defaults to an empty string.middleware
An array of registered
Middleware
. Defaults to an empty array.handler
A handler to call.
Return Value
A new instance of
Route
. -
Creates an array with one or more instances of
Route
based on HTTP request methods provided.Declaration
Swift
@discardableResult public func request( _ path: String = Route.defaultPath, methods: Set<Request.Method> = Set(Request.Method.allCases), middleware: [Middleware] = .init(), handler: @escaping Route.Handler ) -> [Route]
Parameters
path
A path to a resource. Defaults to
/
.methods
An array of HTTP request methods. Defaults to all supported HTTP request methods.
middleware
An array of registered
Middleware
. Defaults to an empty array.handler
A handler to call.
Return Value
An array with one or more instances of
Route
. -
Creates a new child instance/node of
Builder
withRouteCollection
.Declaration
Swift
public func grouped( _ path: String = Route.defaultPath, name: String = "", middleware: [Middleware] = .init() ) -> Builder?
Parameters
path
A path prefix to a resource. Defaults to
/
.name
A name prefix for
Route
s. Defaults to an empty string.middleware
An array of registered
Middleware
. Defaults to an empty array.Return Value
A new child instance/node of
Builder
. -
Creates a new child instance/node of
Builder
withRouteCollection
.Declaration
Swift
public func group( _ path: String = Route.defaultPath, name: String = "", middleware: [Middleware] = .init(), handler: @escaping (Builder) -> Void )
Parameters
path
A path prefix to a resource. Defaults to
/
.name
A name prefix for
Route
s. Defaults to an empty string.middleware
An array of registered
Middleware
. Defaults to an empty array.handler
A handler with a new child instance/node of
Builder
.