Ejemplo n.º 1
0
 /// <summary>
 /// Adds a handler to a <see cref="RoutingModule"/>.
 /// </summary>
 /// <param name="this">The <see cref="RoutingModule"/> on which this method is called.</param>
 /// <param name="verb">A <see cref="HttpVerb"/> constant representing the HTTP method
 /// to associate with <paramref name="handler"/>, or <see cref="HttpVerb.Any"/>
 /// if <paramref name="handler"/> can handle all HTTP methods.</param>
 /// <param name="matcher">The <see cref="RouteMatcher"/> used to match URL paths.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <returns><paramref name="this"/> with the handler added.</returns>
 /// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="matcher"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <seealso cref="RoutingModule.Add(HttpVerb,RouteMatcher,RouteHandlerCallback)"/>
 public static RoutingModule Handle(this RoutingModule @this, HttpVerb verb, RouteMatcher matcher, RouteHandlerCallback handler)
 {
     @this.Add(verb, matcher, handler);
     return(@this);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Associates all requests matching a route to a handler.
 /// </summary>
 /// <param name="this">The <see cref="RoutingModule"/> on which this method is called.</param>
 /// <param name="matcher">The <see cref="RouteMatcher"/> used to match URL paths.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <returns><paramref name="this"/> with the handler added.</returns>
 /// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="matcher"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 public static RoutingModule OnAny(this RoutingModule @this, RouteMatcher matcher, RouteHandlerCallback handler)
 {
     @this.Add(HttpVerb.Any, matcher, handler);
     return(@this);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Associates <c>PUT</c> requests matching a route to a handler.
 /// </summary>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 protected void OnPut(string route, RouteHandlerCallback handler)
 => _resolvers.Add(HttpVerbs.Put, route, handler);
Ejemplo n.º 4
0
 /// <summary>
 /// Associates a HTTP method and a route to a handler.
 /// </summary>
 /// <param name="verb">A <see cref="HttpVerbs"/> constant representing the HTTP method
 /// to associate with <paramref name="handler"/>, or <see cref="HttpVerbs.Any"/>
 /// if <paramref name="handler"/> can handle all HTTP methods.</param>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 protected void AddHandler(HttpVerbs verb, string route, RouteHandlerCallback handler)
 => _resolvers.Add(verb, route, handler);
Ejemplo n.º 5
0
 /// <summary>
 /// Associates <c>PUT</c> requests matching a route to a handler.
 /// </summary>
 /// <param name="this">The <see cref="RoutingModule"/> on which this method is called.</param>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="isBaseRoute"><see langword="true"/> if <paramref name="route"/>
 /// is a base route; <see langword="false"/> if <paramref name="route"/>
 /// is a terminal (non-base) route.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <returns><paramref name="this"/> with the handler added.</returns>
 /// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 public static RoutingModule OnPut(this RoutingModule @this, string route, bool isBaseRoute, RouteHandlerCallback handler)
 {
     @this.Add(HttpVerb.Put, RouteMatcher.Parse(route, isBaseRoute), handler);
     return(@this);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Associates <c>OPTIONS</c> requests matching a route to a handler.
 /// </summary>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 protected void OnOptions(string route, RouteHandlerCallback handler)
 => _resolvers.Add(HttpVerbs.Options, route, handler);
Ejemplo n.º 7
0
 /// <summary>
 /// Associates a HTTP method and a route to a handler.
 /// </summary>
 /// <param name="verb">A <see cref="HttpVerb"/> constant representing the HTTP method
 /// to associate with <paramref name="handler"/>, or <see cref="HttpVerb.Any"/>
 /// if <paramref name="handler"/> can handle all HTTP methods.</param>
 /// <param name="matcher">The <see cref="RouteMatcher"/> used to match URL paths.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="matcher"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 protected void AddHandler(HttpVerb verb, RouteMatcher matcher, RouteHandlerCallback handler)
 => _resolvers.Add(verb, matcher, handler);
Ejemplo n.º 8
0
 /// <summary>
 /// Associates some data and a route to a handler.
 /// </summary>
 /// <param name="data">Data used to determine which contexts are
 /// suitable to be handled by <paramref name="handler"/>.</param>
 /// <param name="matcher">The <see cref="RouteMatcher"/>to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="matcher"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="InvalidOperationException">The <see cref="CreateResolver"/> method
 /// returned <see langword="null"/>.</exception>
 /// <seealso cref="ResolveAsync"/>
 /// <seealso cref="Add(TData,RouteMatcher,SyncRouteHandlerCallback)"/>
 /// <seealso cref="RouteResolverBase{TData}.Add(TData,RouteHandlerCallback)"/>
 public void Add(TData data, RouteMatcher matcher, RouteHandlerCallback handler)
 {
     matcher = Validate.NotNull(nameof(matcher), matcher);
     handler = Validate.NotNull(nameof(handler), handler);
     GetResolver(matcher).Add(data, handler);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Associates <c>OPTIONS</c> requests matching a route to a handler.
 /// </summary>
 /// <param name="matcher">The <see cref="RouteMatcher"/> used to match URL paths.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="matcher"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 protected void OnOptions(RouteMatcher matcher, RouteHandlerCallback handler)
 => _resolvers.Add(HttpVerb.Options, matcher, handler);
Ejemplo n.º 10
0
 /// <summary>
 /// Associates <c>PUT</c> requests matching a route to a handler.
 /// </summary>
 /// <param name="matcher">The <see cref="RouteMatcher"/> used to match URL paths.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="matcher"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 protected void OnPut(RouteMatcher matcher, RouteHandlerCallback handler)
 => _resolvers.Add(HttpVerb.Put, matcher, handler);
Ejemplo n.º 11
0
 /// <summary>
 /// Associates <c>DELETE</c> requests matching a route to a handler.
 /// </summary>
 /// <param name="matcher">The <see cref="RouteMatcher"/> used to match URL paths.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="matcher"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 protected void OnDelete(RouteMatcher matcher, RouteHandlerCallback handler)
 => _resolvers.Add(HttpVerb.Delete, matcher, handler);
Ejemplo n.º 12
0
 /// <summary>
 /// Associates a HTTP method and a route to a handler.
 /// </summary>
 /// <param name="verb">A <see cref="HttpVerbs"/> constant representing the HTTP method
 /// to associate with <paramref name="handler"/>, or <see cref="HttpVerbs.Any"/>
 /// if <paramref name="handler"/> can handle all HTTP methods.</param>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 public void Add(HttpVerbs verb, string route, RouteHandlerCallback handler)
 => AddHandler(verb, route, handler);
 /// <summary>
 /// Associates some data and a route to a handler.
 /// </summary>
 /// <param name="data">Data used to determine which contexts are
 /// suitable to be handled by <paramref name="handler"/>.</param>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 /// <exception cref="InvalidOperationException">The <see cref="CreateResolver"/> method
 /// returned <see langword="null"/>.</exception>
 /// <seealso cref="ResolveAsync"/>
 /// <seealso cref="Add(TData,string,SyncRouteHandlerCallback)"/>
 /// <seealso cref="RouteResolverBase{TData}.Add(TData,RouteHandlerCallback)"/>
 public void Add(TData data, string route, RouteHandlerCallback handler)
 {
     handler = Validate.NotNull(nameof(handler), handler);
     GetResolver(route).Add(data, handler);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Adds a handler to a <see cref="RoutingModule"/>.
 /// </summary>
 /// <param name="this">The <see cref="RoutingModule"/> on which this method is called.</param>
 /// <param name="verb">A <see cref="HttpVerbs"/> constant representing the HTTP method
 /// to associate with <paramref name="handler"/>, or <see cref="HttpVerbs.Any"/>
 /// if <paramref name="handler"/> can handle all HTTP methods.</param>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <returns><paramref name="this"/> with the handler added.</returns>
 /// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 /// <seealso cref="RoutingModule.Add(HttpVerbs,string,RouteHandlerCallback)"/>
 public static RoutingModule Handle(this RoutingModule @this, HttpVerbs verb, string route, RouteHandlerCallback handler)
 {
     @this.Add(verb, route, handler);
     return(@this);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Associates a HTTP method and a route to a handler.
 /// </summary>
 /// <param name="verb">A <see cref="HttpVerb"/> constant representing the HTTP method
 /// to associate with <paramref name="handler"/>, or <see cref="HttpVerb.Any"/>
 /// if <paramref name="handler"/> can handle all HTTP methods.</param>
 /// <param name="matcher">The <see cref="RouteMatcher"/> used to match URL paths.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="matcher"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 public void Add(HttpVerb verb, RouteMatcher matcher, RouteHandlerCallback handler)
 => AddHandler(verb, matcher, handler);
Ejemplo n.º 16
0
 /// <summary>
 /// Associates all requests matching a route to a handler.
 /// </summary>
 /// <param name="this">The <see cref="RoutingModule"/> on which this method is called.</param>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <returns><paramref name="this"/> with the handler added.</returns>
 /// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 public static RoutingModule OnAny(this RoutingModule @this, string route, RouteHandlerCallback handler)
 {
     @this.Add(HttpVerbs.Any, route, handler);
     return(@this);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Associates <c>DELETE</c> requests matching a route to a handler.
 /// </summary>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 protected void OnDelete(string route, RouteHandlerCallback handler)
 => _resolvers.Add(HttpVerbs.Delete, route, handler);
Ejemplo n.º 18
0
 /// <summary>
 /// Associates all requests matching a route to a handler.
 /// </summary>
 /// <param name="this">The <see cref="RoutingModule"/> on which this method is called.</param>
 /// <param name="route">The route to match URL paths against.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <returns><paramref name="this"/> with the handler added.</returns>
 /// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="route"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="FormatException"><paramref name="route"/> is not a valid route.</exception>
 public static RoutingModule OnAny(this RoutingModule @this, string route, RouteHandlerCallback handler)
 {
     @this.Add(HttpVerbs.Any, RouteMatcher.Parse(route, false), handler);
     return(@this);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Associates <c>HEAD</c> requests matching a route to a handler.
 /// </summary>
 /// <param name="matcher">The <see cref="RouteMatcher"/> used to match URL paths.</param>
 /// <param name="handler">A callback used to handle matching contexts.</param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="matcher"/> is <see langword="null"/>.</para>
 /// <para>- or -</para>
 /// <para><paramref name="handler"/> is <see langword="null"/>.</para>
 /// </exception>
 protected void OnHead(RouteMatcher matcher, RouteHandlerCallback handler)
 => _resolvers.Add(HttpVerbs.Head, matcher, handler);