예제 #1
0
        RedirectToCurrentApiVersion(
            this INugetServerProvider provider,
            HttpContext context,
            bool permanent = true)
        {
            var currentVersion = provider.GetApiMajorVersionUrl();
            var paths          = context.Request.Path
                                 .ToString()
                                 .Split(new[] { '/' },
                                        StringSplitOptions.RemoveEmptyEntries);
            string newPath = currentVersion;

            if (paths.Length > 0)
            {
                var otherPaths = paths.Skip(1);
                if (otherPaths.Any())
                {
                    newPath = newPath + "/" + string.Join("/", otherPaths);
                }
            }
            if (context.Request.QueryString.HasValue)
            {
                newPath += context.Request.QueryString.Value;
            }
            context.Response.Redirect(newPath, permanent);
        }
예제 #2
0
        private static PathString GetServiceIndexUrlPath(
            this INugetServerProvider provider)
        {
            var majorVersion = provider
                               .GetApiMajorVersionUrl();

            var path = provider
                       ?.NugetServerOptions
                       ?.ServiceIndex
                       ?? throw new InvalidOperationException(
                                 "Nuget server index not specified.");

            return(majorVersion + path);
        }