예제 #1
0
        public IRoute Add(string method, string name, string routePattern, RouteFuncAsync handler)
        {
            var route = new Route(method, name, GetPrefixedRoute(routePattern), handler);

            _routeManager.Add(route);

            return(route);
        }
예제 #2
0
        internal Route(string method, string name, string route, RouteFuncAsync handlerFunc)
        {
            _middlewareManager = new MiddlewareManager();

            _method      = method;
            _name        = name;
            _route       = route;
            _handlerFunc = handlerFunc;

            _regex = RouteToRegex(route);
        }
예제 #3
0
        public MiddlewareRuntime(
            IEnumerable <RouteFuncAsyncMiddleware> routeFuncAsyncMiddlewareList,
            RouteFuncAsync handlerFunc
            )
        {
            _handlerFunc = handlerFunc;
            foreach (var routeFuncAsyncMiddleware in routeFuncAsyncMiddlewareList)
            {
                var middleware = new Middleware
                {
                    Next        = context => _handlerFunc(context),
                    HandlerFunc = routeFuncAsyncMiddleware
                };

                if (_middleware == null)
                {
                    _middleware = middleware;
                }
                else
                {
                    _middleware.Next = middleware.Invoke;
                }
            }
        }
예제 #4
0
 public RequestHandler(RouteFuncAsync handlerFunc, Context context)
 {
     _handlerFunc = handlerFunc;
     _context     = context;
 }
예제 #5
0
 public MiddlewareRuntime GetRuntime(RouteFuncAsync handlerFunc)
 {
     return(new MiddlewareRuntime(_middleware, handlerFunc));
 }
예제 #6
0
 public static IRoute Patch(this IRouteConfigurator routeConfigurator, string name, string path,
                            RouteFuncAsync handler)
 {
     return(routeConfigurator.Add("PATCH", name, path, handler));
 }
예제 #7
0
 public static IRoute Trace(this IRouteConfigurator routeConfigurator, string name, string path,
                            RouteFuncAsync handler)
 {
     return(routeConfigurator.Add("TRACE", name, path, handler));
 }
예제 #8
0
 public static IRoute Options(this IRouteConfigurator routeConfigurator, string name,
                              string path,
                              RouteFuncAsync handler)
 {
     return(routeConfigurator.Add("OPTIONS", name, path, handler));
 }
예제 #9
0
 public static IRoute Connect(this IRouteConfigurator routeConfigurator, string name,
                              string path,
                              RouteFuncAsync handler)
 {
     return(routeConfigurator.Add("CONNECT", name, path, handler));
 }
예제 #10
0
 public static IRoute Delete(this IRouteConfigurator routeConfigurator, string name, string path,
                             RouteFuncAsync handler)
 {
     return(routeConfigurator.Add("DELETE", name, path, handler));
 }
예제 #11
0
 public static IRoute Head(this IRouteConfigurator routeConfigurator, string name, string path,
                           RouteFuncAsync handler)
 {
     return(routeConfigurator.Add("HEAD", name, path, handler));
 }