Support FormatFilter for all controllers
This commit is contained in:
parent
acb9457253
commit
0036a5eeec
@ -1,13 +1,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
|
|
||||||
namespace ASC.Employee.Core.Controllers
|
namespace ASC.Employee.Core.Controllers
|
||||||
{
|
{
|
||||||
[FormatFilter]
|
|
||||||
[Route("api/2.0/[controller]")]
|
[Route("api/2.0/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
|
||||||
public class PeopleController : ControllerBase
|
public class PeopleController : ControllerBase
|
||||||
{
|
{
|
||||||
// GET api/values
|
// GET api/values
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
using ASC.Common.Data;
|
|
||||||
using ASC.Common.Utils;
|
|
||||||
using ASC.Core;
|
|
||||||
using ASC.Core.Security.Authentication;
|
|
||||||
using ASC.Security.Cryptography;
|
|
||||||
using ASC.Web.Api.Handlers;
|
using ASC.Web.Api.Handlers;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
@ -22,7 +20,6 @@ namespace ASC.Web.Api
|
|||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddControllers()
|
services.AddControllers()
|
||||||
@ -31,11 +28,14 @@ namespace ASC.Web.Api
|
|||||||
|
|
||||||
services.AddHttpContextAccessor();
|
services.AddHttpContextAccessor();
|
||||||
|
|
||||||
services.AddAuthentication("cookie")
|
services.AddAuthentication("cookie").AddScheme<AuthenticationSchemeOptions, CookieAuthHandler>("cookie", a=> { });
|
||||||
.AddScheme<AuthenticationSchemeOptions, CookieAuthHandler>("cookie", a=> { });
|
|
||||||
|
services.AddMvc(config =>
|
||||||
|
{
|
||||||
|
config.Filters.Add(new TypeFilterAttribute(typeof(FormatFilter)));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
@ -48,7 +48,6 @@ namespace ASC.Web.Api
|
|||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user