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