Integrate ApiVersioning library for ASP.NET
This commit is contained in:
parent
db1ebd0a1d
commit
c4c3eaf954
@ -9,8 +9,9 @@ using PluralKit.Core;
|
||||
namespace PluralKit.API
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[Route("a")]
|
||||
[Route("v1/a")]
|
||||
[Route( "v{version:apiVersion}/a" )]
|
||||
public class AccountController: ControllerBase
|
||||
{
|
||||
private IDataStore _data;
|
||||
|
@ -9,8 +9,9 @@ using PluralKit.Core;
|
||||
namespace PluralKit.API
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[Route("m")]
|
||||
[Route("v1/m")]
|
||||
[Route( "v{version:apiVersion}/m" )]
|
||||
public class MemberController: ControllerBase
|
||||
{
|
||||
private IDataStore _data;
|
||||
|
@ -24,8 +24,9 @@ namespace PluralKit.API
|
||||
}
|
||||
|
||||
[ApiController]
|
||||
[Route("v1/msg")]
|
||||
[ApiVersion("1.0")]
|
||||
[Route("msg")]
|
||||
[Route( "v{version:apiVersion}/msg" )]
|
||||
public class MessageController: ControllerBase
|
||||
{
|
||||
private IDataStore _data;
|
||||
|
@ -34,8 +34,9 @@ namespace PluralKit.API
|
||||
}
|
||||
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[Route("s")]
|
||||
[Route("v1/s")]
|
||||
[Route( "v{version:apiVersion}/s" )]
|
||||
public class SystemController : ControllerBase
|
||||
{
|
||||
private IDataStore _data;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
using Autofac;
|
||||
|
||||
@ -29,6 +29,12 @@ namespace PluralKit.API
|
||||
services.AddControllers()
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Latest)
|
||||
.AddNewtonsoftJson(); // sorry MS, this just does *more*
|
||||
|
||||
services.AddApiVersioning(c =>
|
||||
{
|
||||
c.AssumeDefaultVersionWhenUnspecified = true;
|
||||
c.DefaultApiVersion = ApiVersion.Parse("1.0");
|
||||
});
|
||||
}
|
||||
|
||||
public void ConfigureContainer(ContainerBuilder builder)
|
||||
|
Loading…
Reference in New Issue
Block a user