Router
public class Router
The Router
class provides the external interface for the routing of requests to
the appropriate code for handling. This includes:
- Routing requests to closures with the signature of
RouterHandler
- Routing requests to the handle function of classes that implement the
RouterMiddleware
protocol. - Routing the request to a template engine to generate the appropriate output.
- Serving the landing page when someone makes an HTTP request with a path of slash (/).
-
The root directory for templates that will be automatically handed over to an appropriate templating engine for content generation.
Declaration
Swift
public var viewsPath = "./Views/"
-
Initialize a
Router
instanceDeclaration
Swift
public init(mergeParameters: Bool = false)
Parameters
mergeParameters
Specify if this router should have access to path parameters matched in its parent router. Defaults to
false
.
-
Sets the default templating engine to be used when the extension of a file in the
viewsPath
doesn’t match the extension of one of the registered templating engines.Declaration
Swift
public func setDefault(templateEngine: TemplateEngine?)
Parameters
templateEngine
The new default templating engine
-
Register a templating engine. The templating engine will handle files in the
viewsPath
that match the extension it supports.Declaration
Swift
public func add(templateEngine: TemplateEngine, forFileExtensions fileExtensions: [String] = [], useDefaultFileExtension: Bool = true)
Parameters
templateEngine
The templating engine to register.
forFileExtensions
The extensions of the files to apply the template engine on.
useDefaultFileExtension
flag to specify if the default file extension of the template engine should be used
-
Setup a
sub router
to handle requests. This can make it easier to build a server that serves a large set of paths, by breaking it up in tosub router
where each sub router is mapped to it’s own root path and handles all of the mappings of paths below that.Declaration
Swift
public func route(_ route: String, mergeParameters: Bool = false, allowPartialMatch: Bool = true) -> Router
Parameters
route
The path to bind the sub router to.
mergeParameters
Specify if this router should have access to path parameters matched in its parent router. Defaults to
false
.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
Return Value
The created sub router.
-
Setup a handler for specific name of request parameters. This can make it easier to handle values of provided parameter name.
Declaration
Swift
public func parameter(_ name: String, handler: RouterParameterHandler...) -> Router
Parameters
name
A single parameter name to be handled
handler
A comma delimited set of
RouterParameterHandler
s that will be invoked when request parses a parameter with specified name.Return Value
Current router instance
-
Setup a handler for specific name of request parameters. This can make it easier to handle values of provided parameter name.
Declaration
Swift
public func parameter(_ names: [String], handler: RouterParameterHandler...) -> Router
Parameters
names
The array of parameter names that will be used to invoke handlers
handler
A comma delimited set of
RouterParameterHandler
s that will be invoked when request parses a parameter with specified name.Return Value
Current router instance
-
Setup a handler for specific name of request parameters. This can make it easier to handle values of provided parameter name.
Declaration
Swift
public func parameter(_ names: [String], handlers: [RouterParameterHandler]) -> Router
Parameters
names
The array of parameter names that will be used to invoke handlers
handlers
The array of
RouterParameterHandler
s that will be invoked when request parses a parameter with specified name.Return Value
Current router instance
-
Setup a CodableArrayClosure on the provided route which will be invoked when a request comes to the server.
Usage Example:
//User is a struct object that conforms to Codable router.get("/users") { (respondWith: ([User]?, RequestError?) -> Void) in ... respondWith(users, nil) }
Declaration
Swift
public func get<O: Codable>(_ route: String, handler: @escaping CodableArrayClosure<O>)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
A CodableArrayClosure that gets invoked when a request comes to the server.
-
Setup a SimpleCodableClosure on the provided route which will be invoked when a request comes to the server.
Usage Example:
//Status is a struct object that conforms to Codable router.get("/status") { (respondWith: (Status?, RequestError?) -> Void) in ... respondWith(status, nil) }
Declaration
Swift
public func get<O: Codable>(_ route: String, handler: @escaping SimpleCodableClosure<O>)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
A SimpleCodableClosure that gets invoked when a request comes to the server.
-
Setup a IdentifierSimpleCodableClosure on the provided route which will be invoked when a request comes to the server.
Usage Example:
//User is a struct object that conforms to Codable router.get("/users") { (id: Int, respondWith: (User?, RequestError?) -> Void) in ... respondWith(user, nil) }
Declaration
Swift
public func get<Id: Identifier, O: Codable>(_ route: String, handler: @escaping IdentifierSimpleCodableClosure<Id, O>)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
An IdentifierSimpleCodableClosure that gets invoked when a request comes to the server.
-
Setup a (QueryParams, CodableArrayResultClosure) -> Void on the provided route which will be invoked when a request comes to the server.
Usage Example:
// MyQuery is a codable struct defining the supported query parameters // User is a struct object that conforms to Codable router.get("/query") { (query: MyQuery, respondWith: ([User]?, RequestError?) -> Void) in ... respondWith(users, nil) }
Declaration
Swift
public func get<Q: QueryParams, O: Codable>(_ route: String, handler: @escaping (Q, @escaping CodableArrayResultClosure<O>) -> Void)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
A (QueryParams, CodableArrayResultClosure) -> Void that gets invoked when a request comes to the server.
-
Setup a NonCodableClosure on the provided route which will be invoked when a request comes to the server.
Usage Example:
router.delete("/users") { (respondWith: (RequestError?) -> Void) in ... respondWith(nil) }
Declaration
Swift
public func delete(_ route: String, handler: @escaping NonCodableClosure)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
An NonCodableClosure that gets invoked when a request comes to the server.
-
Setup a IdentifierNonCodableClosure on the provided route which will be invoked when a request comes to the server.
Usage Example:
router.delete("/users") { (id: Int, respondWith: (RequestError?) -> Void) in ... respondWith(nil) }
Declaration
Swift
public func delete<Id: Identifier>(_ route: String, handler: @escaping IdentifierNonCodableClosure<Id>)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
An IdentifierNonCodableClosure that gets invoked when a request comes to the server.
-
Setup a (QueryParams, ResultClosure) -> Void on the provided route which will be invoked when a request comes to the server.
Usage Example:
// MyQuery is a codable struct defining the supported query parameters router.delete("/query") { (query: MyQuery, respondWith: (RequestError?) -> Void) in ... respondWith(nil) }
Declaration
Swift
public func delete<Q: QueryParams>(_ route: String, handler: @escaping (Q, @escaping ResultClosure) -> Void)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
A (QueryParams, ResultClosure) -> Void that gets invoked when a request comes to the server.
-
Setup a CodableClosure on the provided route which will be invoked when a POST request comes to the server. In this scenario, the ID (i.e. unique identifier) is a field in the Codable instance.
Usage Example:
//User is a struct object that conforms to Codable router.post("/users") { (user: User, respondWith: (User?, RequestError?) -> Void) in ... respondWith(user, nil) }
Declaration
Swift
public func post<I: Codable, O: Codable>(_ route: String, handler: @escaping CodableClosure<I, O>)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
A Codable closure that gets invoked when a request comes to the server.
-
Setup a CodableIdentifierClosure on the provided route which will be invoked when a POST request comes to the server. In this scenario, the ID (i.e. unique identifier) for the Codable instance is a separate field (which is sent back to the client in the location HTTP header).
Usage Example:
//User is a struct object that conforms to Codable router.post("/users") { (user: User, respondWith: (Int?, User?, RequestError?) -> Void) in ... respondWith(id, user, nil) }
Declaration
Swift
public func post<I: Codable, Id: Identifier, O: Codable>(_ route: String, handler: @escaping CodableIdentifierClosure<I, Id, O>)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
A Codable closure that gets invoked when a request comes to the server.
-
Setup a IdentifierCodableClosure on the provided route which will be invoked when a request comes to the server.
Usage Example:
//User is a struct object that conforms to Codable router.put("/users") { (id: Int, user: User, respondWith: (User?, RequestError?) -> Void) in ... respondWith(user, nil) }
Declaration
Swift
public func put<Id: Identifier, I: Codable, O: Codable>(_ route: String, handler: @escaping IdentifierCodableClosure<Id, I, O>)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
An Identifier Codable closure that gets invoked when a request comes to the server.
-
Setup a IdentifierCodableClosure on the provided route which will be invoked when a request comes to the server.
Usage Example:
//User is a struct object that conforms to Codable //OptionalUser is a struct object that conforms to Codable where all properties are optional router.patch("/users") { (id: Int, patchUser: OptionalUser, respondWith: (User?, RequestError?) -> Void) -> Void in ... respondWith(user, nil) }
Declaration
Swift
public func patch<Id: Identifier, I: Codable, O: Codable>(_ route: String, handler: @escaping IdentifierCodableClosure<Id, I, O>)
Parameters
route
A String specifying the pattern that needs to be matched, in order for the handler to be invoked.
handler
An Identifier Codable closure that gets invoked when a request comes to the server.
-
Handle an HTTP request as a middleware. Used for sub routing.
Declaration
Swift
public func handle(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throws
Parameters
request
The
RouterRequest
object that is used to work with the incoming request.response
The
RouterResponse
object used to send responses to the HTTP request.next
The closure to invoke to cause the router to inspect the path in the list of paths.
-
Handle the HTTP request
Declaration
Swift
public func handle(request: ServerRequest, response: ServerResponse)
Parameters
request
The
ServerRequest
object used to work with the incoming HTTP request at the Kitura-net API level.response
The
ServerResponse
object used to send responses to the HTTP request at the Kitura-net API level.
-
Setup error handling that will cause a set of one or more closures of the type
RouterHandler
to be invoked when an error occurs.Declaration
Swift
public func error(_ handler: RouterHandler...) -> Router
Parameters
handler
A comma delimited set of
RouterHandler
that will be invoked if an error ocurrs. -
Setup error handling that will cause an array of one or more closures of the type
RouterHandler
to be invoked when an error occurs.Declaration
Swift
public func error(_ handler: [RouterHandler]) -> Router
Parameters
handler
An array of
RouterHandler
that will be invoked if an error ocurrs. -
Setup error handling that will cause a set of one or more
RouterMiddleware
to be invoked when an error occurs.Declaration
Swift
public func error(_ middleware: RouterMiddleware...) -> Router
Parameters
middleware
A comma delimited set of
RouterMiddleware
that will be invoked if an error ocurrs. -
Setup error handling that will cause an array of one or more
RouterMiddleware
to be invoked when an error occurs.Declaration
Swift
public func error(_ middleware: [RouterMiddleware]) -> Router
Parameters
middleware
An array of
RouterMiddleware
that will be invoked if an error ocurrs.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when any request comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func all(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when any request comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when any request comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func all(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when any request comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when any request comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func all(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when any request comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when any request comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func all(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when any request comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP GET requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func get(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP GET requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP GET requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func get(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP GET requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP GET requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func get(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP GET requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP GET requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func get(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP GET requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP HEAD requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func head(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP HEAD requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP HEAD requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func head(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP HEAD requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP HEAD requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func head(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP HEAD requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP HEAD requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func head(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP HEAD requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP POST requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func post(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP POST requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP POST requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func post(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP POST requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP POST requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func post(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP POST requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP POST requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func post(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP POST requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP PUT requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func put(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP PUT requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP PUT requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func put(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP PUT requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP PUT requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func put(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP PUT requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP PUT requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func put(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP PUT requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP DELETE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func delete(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP DELETE requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP DELETE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func delete(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP DELETE requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP DELETE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func delete(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP DELETE requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP DELETE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func delete(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP DELETE requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP OPTIONS requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func options(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP OPTIONS requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP OPTIONS requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func options(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP OPTIONS requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP OPTIONS requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func options(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP OPTIONS requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP OPTIONS requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func options(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP OPTIONS requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP TRACE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func trace(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP TRACE requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP TRACE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func trace(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP TRACE requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP TRACE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func trace(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP TRACE requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP TRACE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func trace(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP TRACE requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP COPY requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func copy(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP COPY requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP COPY requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func copy(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP COPY requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP COPY requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func copy(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP COPY requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP COPY requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func copy(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP COPY requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP LOCK requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func lock(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP LOCK requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP LOCK requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func lock(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP LOCK requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP LOCK requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func lock(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP LOCK requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP LOCK requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func lock(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP LOCK requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP MKCOL requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func mkCol(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP MKCOL requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP MKCOL requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func mkCol(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP MKCOL requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP MKCOL requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func mkCol(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP MKCOL requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP MKCOL requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func mkCol(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP MKCOL requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP MOVE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func move(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP MOVE requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP MOVE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func move(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP MOVE requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP MOVE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func move(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP MOVE requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP MOVE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func move(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP MOVE requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP PURGE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func purge(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP PURGE requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP PURGE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func purge(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP PURGE requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP PURGE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func purge(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP PURGE requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP PURGE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func purge(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP PURGE requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP PROPFIND requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func propFind(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP PROPFIND requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP PROPFIND requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func propFind(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP PROPFIND requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP PROPFIND requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func propFind(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP PROPFIND requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP PROPFIND requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func propFind(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP PROPFIND requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP PROPPATCH requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func propPatch(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP PROPPATCH requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP PROPPATCH requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func propPatch(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP PROPPATCH requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP PROPPATCH requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func propPatch(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP PROPPATCH requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP PROPPATCH requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func propPatch(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP PROPPATCH requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP UNLOCK requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func unlock(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP UNLOCK requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP UNLOCK requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func unlock(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP UNLOCK requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP UNLOCK requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func unlock(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP UNLOCK requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP UNLOCK requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func unlock(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP UNLOCK requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP REPORT requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func report(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP REPORT requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP REPORT requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func report(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP REPORT requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP REPORT requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func report(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP REPORT requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP REPORT requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func report(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP REPORT requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP MKACTIVITY requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func mkActivity(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP MKACTIVITY requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP MKACTIVITY requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func mkActivity(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP MKACTIVITY requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP MKACTIVITY requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func mkActivity(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP MKACTIVITY requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP MKACTIVITY requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func mkActivity(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP MKACTIVITY requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP CHECKOUT requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func checkout(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP CHECKOUT requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP CHECKOUT requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func checkout(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP CHECKOUT requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP CHECKOUT requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func checkout(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP CHECKOUT requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP CHECKOUT requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func checkout(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP CHECKOUT requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP MERGE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func merge(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP MERGE requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP MERGE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func merge(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP MERGE requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP MERGE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func merge(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP MERGE requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP MERGE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func merge(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP MERGE requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP MSEARCH requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func mSearch(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP MSEARCH requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP MSEARCH requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func mSearch(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP MSEARCH requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP MSEARCH requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func mSearch(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP MSEARCH requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP MSEARCH requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func mSearch(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP MSEARCH requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP NOTIFY requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func notify(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP NOTIFY requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP NOTIFY requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func notify(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP NOTIFY requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP NOTIFY requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func notify(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP NOTIFY requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP NOTIFY requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func notify(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP NOTIFY requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP SUBSCRIBE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func subscribe(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP SUBSCRIBE requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP SUBSCRIBE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func subscribe(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP SUBSCRIBE requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP SUBSCRIBE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func subscribe(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP SUBSCRIBE requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP SUBSCRIBE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func subscribe(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP SUBSCRIBE requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP UNSUBSCRIBE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func unsubscribe(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP UNSUBSCRIBE requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP UNSUBSCRIBE requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func unsubscribe(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP UNSUBSCRIBE requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP UNSUBSCRIBE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func unsubscribe(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP UNSUBSCRIBE requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP UNSUBSCRIBE requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func unsubscribe(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP UNSUBSCRIBE requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP PATCH requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func patch(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP PATCH requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP PATCH requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func patch(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP PATCH requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP PATCH requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func patch(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP PATCH requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP PATCH requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func patch(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP PATCH requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP SEARCH requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func search(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP SEARCH requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP SEARCH requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func search(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP SEARCH requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP SEARCH requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func search(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP SEARCH requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP SEARCH requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func search(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP SEARCH requests comes to the server.
-
Setup a set of one or more closures of the type
RouterHandler
that will be invoked when HTTP CONNECT requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func connect(_ path: String?=nil, handler: RouterHandler...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
A comma delimited set of
RouterHandler
s that will be invoked when HTTP CONNECT requests comes to the server. -
Setup an array of one or more closures of the type
RouterHandler
that will be invoked when HTTP CONNECT requests comes to the server. If a path pattern is specified, the handlers will only be invoked if the pattern is matched.Declaration
Swift
public func connect(_ path: String?=nil, handler: [RouterHandler]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the handlers to be invoked.
handler
The array of
RouterHandler
s that will be invoked when HTTP CONNECT requests comes to the server. -
Setup a set of one or more
RouterMiddleware
that will be invoked when HTTP CONNECT requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func connect(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: RouterMiddleware...) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
A comma delimited set of
RouterMiddleware
that will be invoked when HTTP CONNECT requests comes to the server. -
Setup an array of one or more
RouterMiddleware
that will be invoked when HTTP CONNECT requests comes to the server. If a path pattern is specified, theRouterMiddleware
will only be invoked if the pattern is matched.Declaration
Swift
public func connect(_ path: String?=nil, allowPartialMatch: Bool = true, middleware: [RouterMiddleware]) -> Router
Parameters
path
An optional String specifying the pattern that needs to be matched, in order for the
RouterMiddleware
to be invoked.allowPartialMatch
A Bool that indicates whether or not a partial match of the path by the pattern is sufficient.
handler
The array of
RouterMiddleware
that will be invoked when HTTP CONNECT requests comes to the server.