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.

Prefix

Gets or sets the prefix which will be applied to all next defining routes in this router.

Methods

AutoScanModules(Type, Assembly)

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)

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.

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.

RegisterValueHandler<T>(RouterActionHandlerCallback<T>)

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

ResolveActionResult(object?)

Resolves the specified object into an valid HttpResponse using the defined value handlers or throws an exception if not possible.

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 for all instance and static methods that are marked with an attribute of type RouteAttribute in the specified object and creates routes for these methods.

SetObject(Type)

Searches for all instance and static methods that are marked with an attribute of type RouteAttribute in the specified object and creates routes for these methods.

SetObject(Type, object)

Searches for all instance and static methods that are marked with an attribute of type RouteAttribute in the specified object and creates routes for these methods.

SetObject<TObject>()

Searches for all instance and static methods that are marked with an attribute of type RouteAttribute in the specified object and creates routes for these methods.

SetObject<TObject>(TObject)

Searches for all instance and static methods that are marked with an attribute of type RouteAttribute in the specified object and creates routes for these methods.

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?, IRequestHandler[])

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

SetRoute(RouteMethod, string, Delegate)

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

SetRoute(RouteMethod, string, Delegate, string?)

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

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.