NuGet/App_Start/NuGetODataConfig.cs

43 lines
1.4 KiB
C#
Raw Permalink Normal View History

2020-09-05 01:46:32 +00:00
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.ExceptionHandling;
using System.Web.Http.Routing;
using NuGet.Server;
using NuGet.Server.Infrastructure;
using NuGet.Server.V2;
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(BinaryDad.NuGet.App_Start.NuGetODataConfig), "Start")]
namespace BinaryDad.NuGet.App_Start
{
public static class NuGetODataConfig
{
public static void Start()
{
ServiceResolver.SetServiceResolver(new DefaultServiceResolver());
var config = GlobalConfiguration.Configuration;
NuGetV2WebApiEnabler.UseNuGetV2WebApiFeed(
config,
"NuGetDefault",
"nuget",
"PackagesOData",
enableLegacyPushRoute: true);
config.Services.Replace(typeof(IExceptionLogger), new TraceExceptionLogger());
// Trace.Listeners.Add(new TextWriterTraceListener(HostingEnvironment.MapPath("~/NuGet.Server.log")));
// Trace.AutoFlush = true;
config.Routes.MapHttpRoute(
name: "NuGetDefault_ClearCache",
routeTemplate: "nuget/clear-cache",
defaults: new { controller = "PackagesOData", action = "ClearCache" },
constraints: new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) }
);
}
}
}