38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
|
using Newtonsoft.Json;
|
|||
|
using Newtonsoft.Json.Serialization;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Web.Http;
|
|||
|
|
|||
|
namespace Simple_Bot_Application
|
|||
|
{
|
|||
|
public static class WebApiConfig
|
|||
|
{
|
|||
|
public static void Register(HttpConfiguration config)
|
|||
|
{
|
|||
|
// Json settings
|
|||
|
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
|
|||
|
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
|||
|
config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
|
|||
|
JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
|
|||
|
{
|
|||
|
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
|||
|
Formatting = Newtonsoft.Json.Formatting.Indented,
|
|||
|
NullValueHandling = NullValueHandling.Ignore,
|
|||
|
};
|
|||
|
|
|||
|
// Web API configuration and services
|
|||
|
|
|||
|
// Web API routes
|
|||
|
config.MapHttpAttributeRoutes();
|
|||
|
|
|||
|
config.Routes.MapHttpRoute(
|
|||
|
name: "DefaultApi",
|
|||
|
routeTemplate: "api/{controller}/{id}",
|
|||
|
defaults: new { id = RouteParameter.Optional }
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|