Пример #1
0
        public HttpRequestMessage RewriteRequest(HttpRequestMessage request, IReadOnlyDictionary <string, string> routeValues)
        {
            var builder = new UriBuilder(request.RequestUri);

            builder.Host = HostTemplate.Rewrite(routeValues);
            builder.Path = PathTemplate.Rewrite(routeValues);
            if (Port == null)
            {
                builder.Port = -1;
            }

            else if (Port != "?")
            {
                builder.Port = int.Parse(Port);
            }


            request.RequestUri = builder.Uri;

            return(request);
        }