/// <summary> /// Route the request. If no route exists, the workflow continues, otherwise, we return the route handler's continuation state. /// </summary> public WorkflowState Route(WorkflowContinuation <ContextWrapper> workflowContinuation, ContextWrapper wrapper) { WorkflowState ret = WorkflowState.Continue; RouteEntry entry = null; Session session = sessionManager != null ? sessionManager[wrapper.Context] : null; PathParams parms = null; // Makes debugging easier to declare these variable here. string verb = wrapper.Context.Verb(); string path = wrapper.Context.Path(); if (routeTable.TryGetRouteEntry(verb, path, wrapper.Context.Request.ContentType, out entry, out parms)) { if (entry.RouteHandler != null) { ret = entry.RouteHandler(workflowContinuation, wrapper, session, parms); } } return(ret); }
protected WorkflowState CheckExpirationAndAuthorization(WorkflowContinuation <HttpListenerContext> workflowContinuation, HttpListenerContext context, Session session) { // Inspect the route to see if we should do session expiration and/or session authorization checks. WorkflowState ret = WorkflowState.Continue; RouteEntry entry = null; if (routeTable.TryGetRouteEntry(context.Verb(), context.Path(), out entry)) { if (entry.SessionExpirationProvider != null) { ret = entry.SessionExpirationProvider(workflowContinuation, context, session); } if (ret == WorkflowState.Continue) { if (entry.AuthorizationProvider != null) { ret = entry.AuthorizationProvider(workflowContinuation, context, session); } } } return(ret); }
/// <summary> /// Adds a unique route. /// </summary> public void AddRoute(string verb, string path, string contentType, RouteEntry route) { AddRoute(NewKey(verb, path, contentType), route); }
/// <summary> /// Adds a unique route. /// </summary> public void AddRoute(string verb, string path, RouteEntry route) { AddRoute(NewKey(verb, path), route); }
/// <summary> /// Add a unique route. /// </summary> public void AddRoute(RouteKey key, RouteEntry route) { routes.ThrowIfKeyExists(key, "The route key " + key.ToString() + " already exists.")[key] = route; }
/// <summary> /// True if the routing table contains the verb-path key. /// </summary> public bool Contains(string verb, string path, string contentType = "*") { RouteEntry entry = Parse(NewKey(verb, path, contentType), new PathParams()); return(entry != null); }
/// <summary> /// True if the routing table contains the verb-path key. /// </summary> public bool ContainsKey(RouteKey key) { RouteEntry entry = Parse(key, new PathParams()); return(entry != null); }
/// <summary> /// Returns true and populates the out entry parameter if the key exists. /// </summary> public bool TryGetRouteEntry(string verb, string path, out RouteEntry entry) { return(routes.TryGetValue(NewKey(verb, path), out entry)); }
/// <summary> /// Returns true and populates the out entry parameter if the key exists. /// </summary> public bool TryGetRouteEntry(RouteKey key, out RouteEntry entry) { return(routes.TryGetValue(key, out entry)); }