示例#1
0
 /// <summary>
 /// Associates all requests matching a route to a synchronous 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, SyncRouteHandlerCallback handler)
 {
     @this.Add(HttpVerbs.Any, RouteMatcher.Parse(route, false), handler);
     return(@this);
 }
示例#2
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,RouteMatcher,RouteHandlerCallback)"/>
 public static RoutingModule Handle(this RoutingModule @this, HttpVerbs verb, string route, RouteHandlerCallback handler)
 {
     @this.Add(verb, RouteMatcher.Parse(route, false), handler);
     return(@this);
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RouteAttribute"/> class.
 /// </summary>
 /// <param name="isBaseRoute"><see langword="true"/> if this attribute represents a base route;
 /// <see langword="false"/> (the default) if it represents a terminal (non-base) route.</param>
 /// <param name="verb">The verb.</param>
 /// <param name="route">The route.</param>
 /// <exception cref="ArgumentNullException"><paramref name="route"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentException">
 /// <para><paramref name="route"/> is empty.</para>
 /// <para>- or -</para>
 /// <para><paramref name="route"/> does not start with a slash (<c>/</c>) character.</para>
 /// <para>- or -</para>
 /// <para><paramref name="route"/> does not comply with route syntax.</para>
 /// </exception>
 /// <seealso cref="Routing.Route.IsValid"/>
 public RouteAttribute(HttpVerb verb, string route, bool isBaseRoute = false)
 {
     Matcher = RouteMatcher.Parse(route, isBaseRoute);
     Verb    = verb;
 }
示例#4
0
 /// <summary>
 /// Associates <c>OPTIONS</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="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 OnOptions(this RoutingModule @this, string route, RouteHandlerCallback handler)
 {
     @this.Add(HttpVerb.Options, RouteMatcher.Parse(route, false), handler);
     return(@this);
 }
示例#5
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="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 OnAny(this RoutingModule @this, string route, bool isBaseRoute, RouteHandlerCallback handler)
 {
     @this.Add(HttpVerb.Any, RouteMatcher.Parse(route, isBaseRoute), handler);
     return(@this);
 }
示例#6
0
 /// <summary>
 /// Adds a synchronous 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="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>
 /// <seealso cref="RoutingModule.Add(HttpVerb,RouteMatcher,RouteHandlerCallback)"/>
 public static RoutingModule Handle(this RoutingModule @this, HttpVerb verb, string route, bool isBaseRoute, SyncRouteHandlerCallback handler)
 {
     @this.Add(verb, RouteMatcher.Parse(route, isBaseRoute), handler);
     return(@this);
 }