From b02205c054c5c24f382d9d01a2f843b2f72d8be1 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 28 Sep 2019 21:30:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20ApiVersion=20=E6=94=AF=E6=8C=81=20NETCo?= =?UTF-8?q?re=203.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj | 1 + src/admin/Bootstrap.Admin/Program.cs | 4 +--- src/admin/Bootstrap.Admin/Startup.cs | 16 +++++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj index dc904a17..b37e3cb9 100644 --- a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -17,6 +17,7 @@ + diff --git a/src/admin/Bootstrap.Admin/Program.cs b/src/admin/Bootstrap.Admin/Program.cs index ecf28057..24283f9c 100644 --- a/src/admin/Bootstrap.Admin/Program.cs +++ b/src/admin/Bootstrap.Admin/Program.cs @@ -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 { diff --git a/src/admin/Bootstrap.Admin/Startup.cs b/src/admin/Bootstrap.Admin/Startup.cs index a6c956c6..ae3f6aa5 100644 --- a/src/admin/Bootstrap.Admin/Startup.cs +++ b/src/admin/Bootstrap.Admin/Startup.cs @@ -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.