-
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 theDELETE
HTTP request method.Declaration
Parameters
path
A path to a resource. Defaults to
Route.defaultPath
.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 theGET
HTTP request method.Declaration
Parameters
path
A path to a resource. Defaults to
Route.defaultPath
.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 theHEAD
HTTP request method.Declaration
Parameters
path
A path to a resource. Defaults to
Route.defaultPath
.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 theOPTIONS
HTTP request method.Declaration
Parameters
path
A path to a resource. Defaults to
Route.defaultPath
.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 thePATCH
HTTP request method.Declaration
Parameters
path
A path to a resource. Defaults to
Route.defaultPath
.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 thePOST
HTTP request method.Declaration
Parameters
path
A path to a resource. Defaults to
Route.defaultPath
.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 thePUT
HTTP request method.Declaration
Parameters
path
A path to a resource. Defaults to
Route.defaultPath
.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
Parameters
path
A path to a resource. Defaults to
Route.defaultPath
.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 of
Builder
withRouteCollection
to group relatedRoute
s.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
Route.defaultPath
.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 of
Builder
. -
Creates a new child instance of
Builder
withRouteCollection
to group relatedRoute
s.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
Route.defaultPath
.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 of
Builder
.