Пример #1
0
        public WebServer(string ip, int port, string urlPrefix = null)
        {
            if (!string.IsNullOrEmpty(urlPrefix))
            {
                if (!urlPrefix.EndsWith("/"))
                {
                    _urlPrefix = urlPrefix + "/";
                }
            }
            Cache = new HttpListenerRequestCache(_urlPrefix);

            var prefix = "http://" + ip + ":" + port + "/";

            Logger.Debug("Listening on: " + prefix);

            Logger.Debug("Url Prefix: " + _urlPrefix);

            _requestHandlers = new List <IApiRequestResponse>();

            _urlParser = new Requesturl(prefix);

            _listener.Prefixes.Add(prefix);

            _listener.Start();
        }
Пример #2
0
 private RequestParameters GetRequestParameters(HttpListenerRequest request, string urlPattern)
 {
     return(new RequestParameters(_urlParser.GetParametersFromUrl(request.Url.ToString(), urlPattern),
                                  Requesturl.GetQueryParametersFromUrl(request.Url.ToString())));
 }