using System.Web.Http;
using Control.Middleware;
using log4net;
using Owin;

namespace Control.HostSetting {
    public class Startup {
        private static readonly ILog log = LogManager.GetLogger(typeof(Startup));

        public void Configuration(IAppBuilder appBuilder)
        {
            // Configure Web API for self-host. 
            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "404",
                routeTemplate: "{*url}",
                defaults: new { controller = "Error", action = "Handle404" }
            );
            config.Formatters.Add(new BrowserJsonFormatter());
            config.EnsureInitialized();
            appBuilder.Use<LoggingMiddleware>();
            appBuilder.UseWebApi(config);
        }
    }
}