feat: ApiVersion 支持 NETCore 3.0

This commit is contained in:
Argo Zhang 2019-09-28 21:30:40 +08:00
parent 260b9b0481
commit b02205c054
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
3 changed files with 11 additions and 10 deletions

View File

@ -17,6 +17,7 @@
<PackageReference Include="Longbow.Logging" Version="3.0.0" />
<PackageReference Include="Longbow.Tasks" Version="2.2.24" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.0.0-preview8.19405.7" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />

View File

@ -1,7 +1,5 @@
using Bootstrap.DataAccess;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace Bootstrap.Admin
{

View File

@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -79,13 +81,13 @@ namespace Bootstrap.Admin
op.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
JsonConvert.DefaultSettings = () => op.SerializerSettings;
});
//services.AddApiVersioning(option =>
//{
// option.DefaultApiVersion = new ApiVersion(1, 0);
// option.ReportApiVersions = true;
// option.AssumeDefaultVersionWhenUnspecified = true;
// option.ApiVersionReader = ApiVersionReader.Combine(new HeaderApiVersionReader("api-version"), new QueryStringApiVersionReader("api-version"));
//});
services.AddApiVersioning(option =>
{
option.DefaultApiVersion = new ApiVersion(1, 0);
option.ReportApiVersions = true;
option.AssumeDefaultVersionWhenUnspecified = true;
option.ApiVersionReader = ApiVersionReader.Combine(new HeaderApiVersionReader("api-version"), new QueryStringApiVersionReader("api-version"));
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.