You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.2 KiB
34 lines
1.2 KiB
|
4 years ago
|
using Microsoft.Owin.Security.OAuth;
|
||
|
|
using Newtonsoft.Json.Serialization;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Net.Http;
|
||
|
|
using System.Web.Http;
|
||
|
|
|
||
|
|
namespace SpaAspNetCore
|
||
|
|
{
|
||
|
|
public static class WebApiConfig
|
||
|
|
{
|
||
|
|
public static void Register(HttpConfiguration config)
|
||
|
|
{
|
||
|
|
// Конфигурация и службы Web API
|
||
|
|
// Настройка Web API для использования только проверки подлинности посредством маркера-носителя.
|
||
|
|
config.SuppressDefaultHostAuthentication();
|
||
|
|
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
|
||
|
|
|
||
|
|
// Используйте "верблюжий" стиль для данных JSON.
|
||
|
|
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||
|
|
|
||
|
|
// Маршруты Web API
|
||
|
|
config.MapHttpAttributeRoutes();
|
||
|
|
|
||
|
|
config.Routes.MapHttpRoute(
|
||
|
|
name: "DefaultApi",
|
||
|
|
routeTemplate: "api/{controller}/{id}",
|
||
|
|
defaults: new { id = RouteParameter.Optional }
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|