Table of Contents

Class Router

Namespace
Sisk.Core.Routing
Assembly
Sisk.Core.dll

Represents a collection of Route and main executor of actions in the HttpServer.

public sealed class Router
Inheritance
Router
Inherited Members

Constructors

Router()

Creates an new Router instance with default values.

Properties

CallbackErrorHandler

Gets or sets the Router action exception handler.

GlobalRequestHandlers

Gets or sets the global requests handlers that will be executed in all matched routes.

IsReadOnly

Gets an boolean indicating where this Router is read-only or not.

MatchRoutesIgnoreCase

Gets or sets whether this Router will match routes ignoring case.

MethodNotAllowedErrorHandler

Gets or sets the Router "405 Method Not Allowed" handler.

NotFoundErrorHandler

Gets or sets the Router "404 Not Found" handler.

Methods

AutoScanModules(Type, Assembly, bool)

Scans for all types that implements the specified module type and associates an instance of each type to the router.

AutoScanModules<TModule>()

Scans for all types that implements TModule and associates an instance of each type to the router. Note that, TModule must be an RouterModule type and an accessible constructor for each type must be present.

AutoScanModules<TModule>(Assembly, bool)

Scans for all types that implements TModule and associates an instance of each type to the router. Note that, TModule must be an RouterModule type and an accessible constructor for each type must be present.

CombinePaths(params string[])

Combines the specified URL paths into one.

FilesystemCombinePaths(bool, char, ReadOnlySpan<string>)

Normalizes and combines the specified file-system paths into one.

FilesystemCombinePaths(params string[])

Normalizes and combines the specified file-system paths into one, using the default environment directory separator char.

GetDefinedRoutes()

Gets all routes defined on this router instance.

GetRouteFromName(string)

Gets an defined Route by their name property.

GetRouteFromPath(RouteMethod, string)

Gets the first matched Route by their HTTP method and path.

GetRouteFromPath(string)

Gets the first matched Route by their URL path.

IsDefined(RouteMethod, string)

Gets an boolean indicating if there are any route that matches the specified method and route path.

MapAny(string, RouteAction)

Maps an route which matches any HTTP method, using the specified path and action function.

MapDelete(string, RouteAction)

Maps an DELETE route using the specified path and action function.

MapGet(string, RouteAction)

Maps an GET route using the specified path and action function.

MapPatch(string, RouteAction)

Maps an PATCH route using the specified path and action function.

MapPost(string, RouteAction)

Maps an POST route using the specified path and action function.

MapPut(string, RouteAction)

Maps an PUT route using the specified path and action function.

NormalizePath(string, char)

Normalize the given path to use the specified directory separator, trim the last separator and remove empty entries.

RegisterValueHandler<T>(RouterActionHandlerCallback<T>)

Register an type handling association to converting it to an HttpResponse object.

Rewrite(string, string)

Maps a rewrite route, which redirects all requests that match the given path to another path, keeping the body and headers of the original request.

SetObject(object)

Searches in the specified object for instance methods marked with routing attributes, such as RouteAttribute and optionals RequestHandlerAttribute, and creates routes from them. All routes is delegated to the specified instance.

SetObject(Type)

Searches in the specified object for static methods marked with routing attributes, such as RouteAttribute and optionals RequestHandlerAttribute, and creates routes from them.

SetObject<TObject>()

Searches in the specified object for static methods marked with routing attributes, such as RouteAttribute and optionals RequestHandlerAttribute, and creates routes from them.

SetRoute(Route)

Defines an route in this Router instance.

SetRoute(RouteMethod, string, RouteAction)

Defines an route with their method, path and action function.

SetRoute(RouteMethod, string, RouteAction, string?)

Defines an route with their method, path, action function and name.

SetRoute(RouteMethod, string, RouteAction, string?, IRequestHandler[])

Defines an route with their method, path, action function, name and request handlers.

TryResolveActionResult(object?, out HttpResponse?)

Tries to resolve the specified object into an valid HttpResponse using the defined value handlers.

Operators

operator +(Router, Route)

Defines an route to an router.