コード例 #1
0
 public UriToActionMatch(
     ControllerAction controllerAction,
     Func <HttpEntityManager, RequestParams> requestHandler)
 {
     ControllerAction = controllerAction;
     RequestHandler   = requestHandler;
 }
コード例 #2
0
ファイル: UriRouters.cs プロジェクト: danieldeb/EventStore
        public void RegisterAction(ControllerAction action, Func<HttpEntityManager, UriTemplateMatch, RequestParams> handler)
        {
            Ensure.NotNull(action, "action");
            Ensure.NotNull(handler, "handler");

            var segments = new Uri("http://fake" + action.UriTemplate, UriKind.Absolute).Segments;
            RouterNode node = _root;
            foreach (var segm in segments)
            {
                var segment = Uri.UnescapeDataString(segm);
                string path = segment.StartsWith("{*") ? GreedyPlaceholder
                            : segment.StartsWith("{") ? Placeholder
                            : segment;

                RouterNode child;
                if (!node.Children.TryGetValue(path, out child))
                {
                    child = new RouterNode();
                    node.Children.Add(path, child);
                }
                node = child;
            }
            if (node.LeafRoutes.Contains(x => x.Action.Equals(action)))
                throw new ArgumentException("Duplicate route.");
            node.LeafRoutes.Add(new HttpRoute(action, handler));
        }
コード例 #3
0
ファイル: HttpService.cs プロジェクト: tone81/EventStore
        public void RegisterAction(ControllerAction action, Action <HttpEntityManager, UriTemplateMatch> handler)
        {
            Ensure.NotNull(action, "action");
            Ensure.NotNull(handler, "handler");

            _uriRouter.RegisterAction(action, handler);
        }
コード例 #4
0
ファイル: UriRouters.cs プロジェクト: tone81/EventStore
        public void RegisterAction(ControllerAction action, Action <HttpEntityManager, UriTemplateMatch> handler)
        {
            Ensure.NotNull(action, "action");
            Ensure.NotNull(handler, "handler");

            var        segments = new Uri("http://fake" + action.UriTemplate, UriKind.Absolute).Segments;
            RouterNode node     = _root;

            foreach (var segm in segments)
            {
                var    segment = Uri.UnescapeDataString(segm);
                string path    = segment.StartsWith("{*") ? GreedyPlaceholder
                            : segment.StartsWith("{") ? Placeholder
                            : segment;

                RouterNode child;
                if (!node.Children.TryGetValue(path, out child))
                {
                    child = new RouterNode();
                    node.Children.Add(path, child);
                }
                node = child;
            }
            if (node.LeafRoutes.Contains(x => x.Action.Equals(action)))
            {
                throw new ArgumentException("Duplicate route.");
            }
            node.LeafRoutes.Add(new HttpRoute(action, handler));
        }
コード例 #5
0
        public void RegisterCustomAction(ControllerAction action, Func <HttpEntityManager, UriTemplateMatch, RequestParams> handler)
        {
            Ensure.NotNull(action, "action");
            Ensure.NotNull(handler, "handler");

            _uriRouter.RegisterAction(action, handler);
        }
コード例 #6
0
 public UriToActionMatch(UriTemplateMatch templateMatch,
                         ControllerAction controllerAction,
                         Action <HttpEntity, UriTemplateMatch> requestHandler)
 {
     TemplateMatch    = templateMatch;
     ControllerAction = controllerAction;
     RequestHandler   = requestHandler;
 }
コード例 #7
0
 public UriToActionMatch(UriTemplateMatch templateMatch,
                         ControllerAction controllerAction,
                         Func <HttpEntityManager, UriTemplateMatch, RequestParams> requestHandler)
 {
     TemplateMatch    = templateMatch;
     ControllerAction = controllerAction;
     RequestHandler   = requestHandler;
 }
コード例 #8
0
ファイル: UriRouters.cs プロジェクト: tone81/EventStore
 public void RegisterAction(ControllerAction action, Action <HttpEntityManager, UriTemplateMatch> handler)
 {
     if (_actions.Contains(x => x.Action.Equals(action)))
     {
         throw new ArgumentException("Duplicate route.");
     }
     _actions.Add(new HttpRoute(action, handler));
 }
コード例 #9
0
 public UriToActionMatch(UriTemplateMatch templateMatch, 
                         ControllerAction controllerAction, 
                         Func<HttpEntityManager, UriTemplateMatch, RequestParams> requestHandler)
 {
     TemplateMatch = templateMatch;
     ControllerAction = controllerAction;
     RequestHandler = requestHandler;
 }
コード例 #10
0
 public UriToActionMatch(UriTemplateMatch templateMatch, 
                         ControllerAction controllerAction, 
                         Action<HttpEntity, UriTemplateMatch> requestHandler)
 {
     TemplateMatch = templateMatch;
     ControllerAction = controllerAction;
     RequestHandler = requestHandler;
 }
コード例 #11
0
 public void RegisterAction(ControllerAction action,
                            Func <HttpEntityManager, RequestParams> handler)
 {
     if (_actions.Contains(x => x.Action.Equals(action)))
     {
         throw new ArgumentException("Duplicate route.");
     }
     _actions.Add(new HttpRoute(action, handler));
 }
コード例 #12
0
        public void RegisterAction(ControllerAction action, Action <HttpEntityManager, UriTemplateMatch> handler)
        {
            Ensure.NotNull(action, "action");
            Ensure.NotNull(handler, "handler");

            UriRouter.RegisterAction(action, (man, match) => {
                handler(man, match);
                return(new RequestParams(ESConsts.HttpTimeout));
            });
        }
コード例 #13
0
        public void RegisterControllerAction(ControllerAction action, Action <HttpEntity, UriTemplateMatch> handler)
        {
            Ensure.NotNull(action, "action");
            Ensure.NotNull(handler, "handler");

            if (!_actions.ContainsKey(action))
            {
                _actions[action] = handler;
            }
        }
コード例 #14
0
 public bool Equals(ControllerAction other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.UriTemplate, UriTemplate) && Equals(other.HttpMethod, HttpMethod));
 }
コード例 #15
0
        public void RegisterAction(ControllerAction action, Action <HttpEntityManager, UriTemplateMatch> handler)
        {
            Ensure.NotNull(action, "action");
            Ensure.NotNull(handler, "handler");

            _uriRouter.RegisterAction(action, (man, match) => {
                if (_disableAuthorization || Authorized(man.User, action.RequiredAuthorizationLevel))
                {
                    handler(man, match);
                }
                else
                {
                    man.ReplyStatus(EventStore.Transport.Http.HttpStatusCode.Unauthorized, "Unauthorized", (exc) => {
                        Log.Debug("Error while sending reply (http service): {exc}.", exc.Message);
                    });
                }
                return(new RequestParams(ESConsts.HttpTimeout));
            });
        }
コード例 #16
0
ファイル: UriRouters.cs プロジェクト: jjvdangelo/EventStore
 public HttpRoute(ControllerAction action, Action<HttpEntityManager, UriTemplateMatch> handler)
 {
     Action = action;
     Handler = handler;
     UriTemplate = new UriTemplate(action.UriTemplate);
 }
コード例 #17
0
ファイル: UriRouters.cs プロジェクト: tone81/EventStore
 public HttpRoute(ControllerAction action, Action <HttpEntityManager, UriTemplateMatch> handler)
 {
     Action      = action;
     Handler     = handler;
     UriTemplate = new UriTemplate(action.UriTemplate);
 }
コード例 #18
0
ファイル: UriRouters.cs プロジェクト: danieldeb/EventStore
 public void RegisterAction(ControllerAction action, Func<HttpEntityManager, UriTemplateMatch, RequestParams> handler)
 {
     if (_actions.Contains(x => x.Action.Equals(action)))
         throw new ArgumentException("Duplicate route.");
     _actions.Add(new HttpRoute(action, handler));
 }
コード例 #19
0
 public bool Equals(ControllerAction other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.UriTemplate, UriTemplate) && Equals(other.HttpMethod, HttpMethod);
 }
コード例 #20
0
 public HttpRoute(ControllerAction action, Func <HttpEntityManager, UriTemplateMatch, RequestParams> handler)
 {
     Action      = action;
     Handler     = handler;
     UriTemplate = new UriTemplate(action.UriTemplate);
 }
コード例 #21
0
ファイル: UriRouters.cs プロジェクト: danieldeb/EventStore
 public HttpRoute(ControllerAction action, Func<HttpEntityManager, UriTemplateMatch, RequestParams> handler)
 {
     Action = action;
     Handler = handler;
     UriTemplate = new UriTemplate(action.UriTemplate);
 }
コード例 #22
0
 public HttpRoute(ControllerAction action, Func <HttpEntityManager, RequestParams> handler)
 {
     Action  = action;
     Handler = handler;
 }