Inheritance: IHTTPRouteHandler
Exemplo n.º 1
0
 /// <summary>
 /// Adds a route handler for the specified route and HTTP methods, using a delegate.
 /// <para>
 /// 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
 /// <see cref="IHTTPRouteHandler"/> interface.
 /// </para>
 /// </summary>
 /// <param name="route">The route, for example "/hello_world"</param>
 /// <param name="methods">
 /// The HTTP Methods to support. HTTPMethod has the <c>[Flag]</c> metadata,
 /// which makes it possible to support multiple methods in a single page.
 /// </param>
 /// <param name="handlerMethod">A method delegate. See <see cref="HandleRequestDelegate"/> for usage.</param>
 public RouteMapper Add(string route, HTTPMethod methods, HandleRequestDelegate handlerMethod, bool acceptSubroutes = false)
 {
     lock (_lock)
     {
         RouteHandlerDelegate newHandler = new RouteHandlerDelegate(handlerMethod, acceptSubroutes);
         RouteMapper          mapper     = new RouteMapper(route, methods, newHandler);
         _routes.Add(mapper);
         return(mapper);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adds a route handler for the specified route and HTTP methods, using a delegate.
 /// <para>
 /// 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
 /// <see cref="IHTTPRouteHandler"/> interface.
 /// </para>
 /// </summary>
 /// <param name="route">The route, for example "/hello_world"</param>
 /// <param name="methods">
 /// The HTTP Methods to support. HTTPMethod has the <c>[Flag]</c> metadata,
 /// which makes it possible to support multiple methods in a single page.
 /// </param>
 /// <param name="handlerMethod">A method delegate. See <see cref="HandleRequestDelegate"/> for usage.</param>
 public RouteMapper Add(string route, HTTPMethod methods, HandleRequestDelegate handlerMethod, bool acceptSubroutes = false)
 {
     lock (_lock)
     {
         RouteHandlerDelegate newHandler = new RouteHandlerDelegate(handlerMethod, acceptSubroutes);
         RouteMapper mapper = new RouteMapper(route, methods, newHandler);
         _routes.Add(mapper);
         return mapper;
     }
 }