private WEB.RestRequestParameters GetVarParameters(Request httpListenerRequest)
        {
            WEB.RestRequestParameters pathVariables = new WEB.RestRequestParameters();
            //Parameters = parameters;

            foreach (var key in httpListenerRequest.Query.AllKeys)
            {
                if (pathVariables[key] != null)
                {
                    throw new Exception("Parameters of same name provided in request");
                }
                pathVariables[key] = httpListenerRequest.Query[key];
            }

            return(pathVariables);
        }
        public Action <Request, Response> GetRequestHandler(string url, RestMethod method, out RestRequestParameters parameters)
        {
            var digestibleUrl = new RestDigestibleUri(url);

            parameters = new RestRequestParameters();

            foreach (var node in m_handlerNodes)
            {
                if (node.MatchesUriPattern(digestibleUrl))
                {
                    return(node.GetRestRequestHandler(digestibleUrl, method, parameters));
                }
            }

            return(null);
        }
        public Action <Request, Response> GetRestRequestHandler(RestDigestibleUri uri, RestMethod method, RestRequestParameters parameters)
        {
            HandleParameters(uri, parameters);

            if (uri.IsLastNode || this is WildCardUriRequestHandlerNode)
            {
                switch (method)
                {
                case RestMethod.GET:
                    return(HttpGetRequestHandler);

                case RestMethod.POST:
                    return(HttpPostRequestHandler);

                case RestMethod.PUT:
                    return(HttpPutRequestHandler);

                case RestMethod.DELETE:
                    return(HttpDeleteRequestHandler);

                case RestMethod.OPTIONS:
                    return(HttpGetRequestHandler);

                default:
                    throw new ApplicationException("Unknown REST method.");
                }
            }

            uri.NextNode();

            foreach (var childNode in ChildNodes)
            {
                if (childNode.MatchesUriPattern(uri))
                {
                    return(childNode.GetRestRequestHandler(uri, method, parameters));
                }
            }

            return(null);
        }
 protected abstract void HandleParameters(RestDigestibleUri uri, RestRequestParameters parameters);
 protected override void HandleParameters(RestDigestibleUri uri, RestRequestParameters parameters)
 {
     parameters[m_parameterName] = uri.GetCurrentNode();
 }
 protected override void HandleParameters(RestDigestibleUri uri, RestRequestParameters parameters)
 {
 }