Skip to content

Commit

Permalink
(GH-10) use WebActivator Start for routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ferventcoder committed Jan 3, 2018
1 parent afe894c commit 2d95912
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/SimpleChocolateyServer/App_Start/NuGetODataConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Routing;
using NuGet.Server;
using NuGet.Server.V2;

[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(SimpleChocolateyServer.App_Start.NuGetODataConfig), "Start")]

namespace SimpleChocolateyServer.App_Start
{
public static class NuGetODataConfig
{
public static void Start()
{
ServiceResolver.SetServiceResolver(new DefaultServiceResolver());

var config = GlobalConfiguration.Configuration;

NuGetV2WebApiEnabler.UseNuGetV2WebApiFeed(config, "ChocolateyDefault", "chocolatey", "PackagesOData");

config.Routes.MapHttpRoute(
name: "NuGetDefault_ClearCache",
routeTemplate: "chocolatey/clear-cache",
defaults: new { controller = "PackagesOData", action = "ClearCache" },
constraints: new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) }
);

}
}
}
1 change: 1 addition & 0 deletions src/SimpleChocolateyServer/SimpleChocolateyServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<Compile Include="..\SolutionVersion.cs">
<Link>Properties\SolutionVersion.cs</Link>
</Compile>
<Compile Include="App_Start\NuGetODataConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit 2d95912

Please sign in to comment.