src/HttpServer/HttpHandlerBase.cs
/// <summary>
/// Resolve and return the HTTP handler for the HTTP context of request/response
/// </summary>
/// <param name="httpContext">HTTP context of request/response</param>
/// <returns>HTTP handler for processing the request</returns>
Resolve and return the HTTP handler for the HTTP context of request/response
Resolve and return the HTTP handler for the HTTP context of request / response
public virtual IHttpHandler ResolveHandler(HttpContext httpContext)
        {
            IHttpHandler handler = null;
            if (this.Handlers.ContainsKey(httpContext.Request.URL))
            {
                return (IHttpHandler)this.Handlers[httpContext.Request.URL];
            }
            if (httpContext.Request.URL.IndexOf('/') > 0)
            {
                string appUrl = httpContext.Request.URL.Substring(0, httpContext.Request.URL.IndexOf("/"));
                if (this.Handlers.ContainsKey(appUrl))
                {
                    handler = (IHttpHandler)this.Handlers[appUrl];
                }
            }
            return handler;
        }
public virtual IHttpHandler ResolveHandler ( HttpContext httpContext ) { IHttpHandler handler = null ; if ( this . Handlers . ContainsKey ( httpContext . Request . URL ) ) { return ( IHttpHandler ) this . Handlers [ httpContext . Request . URL ] ; } if ( httpContext . Request . URL . IndexOf ( ' ' ) > 0 ) { string appUrl = httpContext . Request . URL . Substring ( 0 , httpContext . Request . URL . IndexOf ( " " ) ) ; if ( this . Handlers . ContainsKey ( appUrl ) ) { handler = ( IHttpHandler ) this . Handlers [ appUrl ] ; } } return handler ; }
Resolve and return the HTTP handler for the HTTP context of request/response
Resolve and return the HTTP handler for the HTTP context of request / response
// check URL for handler // if no handler found then check application handlers // meaning the first part of the url defines which application should handle the request // for example if an request comes to: app1/device/command/parameter // then the application handler should match to app1 and the rest should be handled by the application handler
HTTP handler for processing the request
HTTP handler for processing the request
httpContext
HttpContext
HTTP context of request/response
HTTP context of request / response