public UriToActionMatch( ControllerAction controllerAction, Func <HttpEntityManager, RequestParams> requestHandler) { ControllerAction = controllerAction; RequestHandler = requestHandler; }
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)); }
public void RegisterAction(ControllerAction action, Action <HttpEntityManager, UriTemplateMatch> handler) { Ensure.NotNull(action, "action"); Ensure.NotNull(handler, "handler"); _uriRouter.RegisterAction(action, handler); }
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)); }
public void RegisterCustomAction(ControllerAction action, Func <HttpEntityManager, UriTemplateMatch, RequestParams> handler) { Ensure.NotNull(action, "action"); Ensure.NotNull(handler, "handler"); _uriRouter.RegisterAction(action, handler); }
public UriToActionMatch(UriTemplateMatch templateMatch, ControllerAction controllerAction, Action <HttpEntity, UriTemplateMatch> requestHandler) { TemplateMatch = templateMatch; ControllerAction = controllerAction; RequestHandler = requestHandler; }
public UriToActionMatch(UriTemplateMatch templateMatch, ControllerAction controllerAction, Func <HttpEntityManager, UriTemplateMatch, RequestParams> requestHandler) { TemplateMatch = templateMatch; ControllerAction = controllerAction; RequestHandler = requestHandler; }
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)); }
public UriToActionMatch(UriTemplateMatch templateMatch, ControllerAction controllerAction, Func<HttpEntityManager, UriTemplateMatch, RequestParams> requestHandler) { TemplateMatch = templateMatch; ControllerAction = controllerAction; RequestHandler = requestHandler; }
public UriToActionMatch(UriTemplateMatch templateMatch, ControllerAction controllerAction, Action<HttpEntity, UriTemplateMatch> requestHandler) { TemplateMatch = templateMatch; ControllerAction = controllerAction; RequestHandler = requestHandler; }
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)); }
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)); }); }
public void RegisterControllerAction(ControllerAction action, Action <HttpEntity, UriTemplateMatch> handler) { Ensure.NotNull(action, "action"); Ensure.NotNull(handler, "handler"); if (!_actions.ContainsKey(action)) { _actions[action] = handler; } }
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)); }
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)); }); }
public HttpRoute(ControllerAction action, Action<HttpEntityManager, UriTemplateMatch> handler) { Action = action; Handler = handler; UriTemplate = new UriTemplate(action.UriTemplate); }
public HttpRoute(ControllerAction action, Action <HttpEntityManager, UriTemplateMatch> handler) { Action = action; Handler = handler; UriTemplate = new UriTemplate(action.UriTemplate); }
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)); }
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); }
public HttpRoute(ControllerAction action, Func <HttpEntityManager, UriTemplateMatch, RequestParams> handler) { Action = action; Handler = handler; UriTemplate = new UriTemplate(action.UriTemplate); }
public HttpRoute(ControllerAction action, Func<HttpEntityManager, UriTemplateMatch, RequestParams> handler) { Action = action; Handler = handler; UriTemplate = new UriTemplate(action.UriTemplate); }
public HttpRoute(ControllerAction action, Func <HttpEntityManager, RequestParams> handler) { Action = action; Handler = handler; }