38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System.Web.Http;
|
|
using Kreta.Core.JsonConverter;
|
|
using Kreta.Core.ModelBinder;
|
|
using Kreta.Web.Logging.Interceptors;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Kreta.User.WebApi
|
|
{
|
|
public static class WebApiConfig
|
|
{
|
|
public static void Register(HttpConfiguration config)
|
|
{
|
|
// Web API configuration and services
|
|
var formatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
|
|
|
|
formatter.SerializerSettings = new JsonSerializerSettings
|
|
{
|
|
Formatting = Formatting.Indented,
|
|
TypeNameHandling = TypeNameHandling.None
|
|
};
|
|
|
|
formatter.SerializerSettings.Converters.Add(new StringTrimConverter());
|
|
|
|
// Web API routes
|
|
config.MapHttpAttributeRoutes();
|
|
|
|
//config.Routes.MapHttpRoute(
|
|
// name: "DefaultApi",
|
|
// routeTemplate: "api/{controller}/{id}",
|
|
// defaults: new { id = RouteParameter.Optional }
|
|
//);
|
|
|
|
config.MessageHandlers.Add(new ApiLoggingHandler());
|
|
|
|
config.BindParameter(typeof(string), new StringTrimModelBinder());
|
|
}
|
|
}
|
|
}
|