C# Class Woopsa.RouteSolver

Provides a mechanism to match a URL with an appropriate response.

The RouteSolver is a solution to the common problem of serving web pages based on the request made by a browser. It's an internal part of the WebServer and thus cannot be created from outside.

The public methods, however, allow the user to add routes to the solver using either delegates for simple cases, or classes that implement the WebServer.IHTTPRouteHandler interface.

Afficher le fichier Open project: woopsa-protocol/Woopsa Class Usage Examples

Méthodes publiques

Méthode Description
Add ( string route, HTTPMethod methods, HandleRequestDelegate handlerMethod, bool acceptSubroutes = false ) : RouteMapper

Adds a route handler for the specified route and HTTP methods, using a delegate.

This is useful for quick, one-off serving of pages. For more complex cases, such as serving files from the file system, it is recommended to use the slightly more complex IHTTPRouteHandler interface.

Add ( string route, HTTPMethod methods, IHTTPRouteHandler handler ) : RouteMapper

Adds a route handler for the specified route and HTTP methods, using a class that implements the IHTTPRouteHandler delegate.

Remove ( RouteMapper routeMapper ) : bool
Remove ( string route ) : bool

Méthodes protégées

Méthode Description
OnError ( RoutingErrorType errorType, string message, HTTPRequest request ) : void

Private Methods

Méthode Description
HandleRequest ( HTTPRequest request, HTTPResponse response, Stream stream ) : void
RouteSolver ( ) : System

Method Details

Add() public méthode

Adds a route handler for the specified route and HTTP methods, using a delegate.

This is useful for quick, one-off serving of pages. For more complex cases, such as serving files from the file system, it is recommended to use the slightly more complex IHTTPRouteHandler interface.

public Add ( string route, HTTPMethod methods, HandleRequestDelegate handlerMethod, bool acceptSubroutes = false ) : RouteMapper
route string The route, for example "/hello_world"
methods HTTPMethod /// The HTTP Methods to support. HTTPMethod has the [Flag] metadata, /// which makes it possible to support multiple methods in a single page. ///
handlerMethod HandleRequestDelegate A method delegate. See for usage.
acceptSubroutes bool
Résultat RouteMapper

Add() public méthode

Adds a route handler for the specified route and HTTP methods, using a class that implements the IHTTPRouteHandler delegate.
public Add ( string route, HTTPMethod methods, IHTTPRouteHandler handler ) : RouteMapper
route string The route, for example "/hello_world"
methods HTTPMethod /// The HTTP Methods to support. HTTPMethod has the [Flag] metadata, /// which makes it possible to support multiple methods in a single page. ///
handler IHTTPRouteHandler An object which implements the interface
Résultat RouteMapper

OnError() protected méthode

protected OnError ( RoutingErrorType errorType, string message, HTTPRequest request ) : void
errorType RoutingErrorType
message string
request HTTPRequest
Résultat void

Remove() public méthode

public Remove ( RouteMapper routeMapper ) : bool
routeMapper RouteMapper
Résultat bool

Remove() public méthode

public Remove ( string route ) : bool
route string
Résultat bool