-
Notifications
You must be signed in to change notification settings - Fork 2
/
ApiConfiguration.cs
36 lines (33 loc) · 1.08 KB
/
ApiConfiguration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using Api.Controllers;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace Api
{
public static class ApiConfiguration
{
public static IServiceCollection ConfigureServices(IServiceCollection services)
{
services
.AddMvcCore()
// https://stackoverflow.com/a/53314810
.AddApplicationPart(typeof(CustomersController).Assembly)
.AddAuthorization(options =>
{
options.AddPolicy("mypolicy", policy =>
{
policy.RequireClaim("myclaim");
});
})
.AddJsonFormatters()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
return services;
}
public static void Configure(IApplicationBuilder app, Func<IApplicationBuilder, IApplicationBuilder> configureHost)
{
configureHost(app)
.UseMvc();
}
}
}