init
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System.Web.Http;
|
||||
using Kreta.Core.JsonConverter;
|
||||
using Kreta.Core.ModelBinder;
|
||||
using Kreta.Eugyintezes.WebApi.Infrastructure;
|
||||
using Kreta.Web.Logging.Interceptors;
|
||||
using Newtonsoft.Json;
|
||||
using SimpleInjector;
|
||||
using SimpleInjector.Integration.WebApi;
|
||||
using SimpleInjector.Lifestyles;
|
||||
|
||||
namespace Kreta.Eugyintezes.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());
|
||||
|
||||
var container = new Container();
|
||||
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
|
||||
|
||||
DependencyInjection.RegisterTypes(container);
|
||||
|
||||
container.RegisterWebApiControllers(config);
|
||||
|
||||
container.Verify();
|
||||
|
||||
config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
|
||||
|
||||
config.BindParameter(typeof(string), new StringTrimModelBinder());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user