public void Configuration(IAppBuilder appBuilder, IKernel kernel) { var name = typeof(Startup).Namespace; try { LogTo.Debug($"Configuring {name}..."); var config = new HttpConfiguration(); RaygunWebApiClient.Attach(config); config.BindParameter(typeof(RaygunMessage), new RaygunMessageBinder()); config.Filters.Add(new ModelStateFilterAttribute()); config.Filters.Add(kernel.Get <AuthenticateApiKeyFilterAttribute>()); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute("DefaultApi", "{controller}/{id}", new { id = RouteParameter.Optional }); config.Services.Add(typeof(IExceptionLogger), new LibLogExceptionLogger()); appBuilder.UseNinjectMiddleware(() => kernel).UseNinjectWebApi(config); LogTo.Debug($"Successfully configured {name}."); } catch (Exception exception) { LogTo.ErrorException($"Configuring {name} failed.", exception); throw; } }
public static void Register(HttpConfiguration config) { RaygunWebApiClient.Attach(config); // Web API configuration and services var jsonFormatter = new JsonMediaTypeFormatter(); config.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator(jsonFormatter)); var settings = jsonFormatter.SerializerSettings; settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; settings.Formatting = Formatting.Indented; settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // Configure Web API with the dependency resolver. GlobalConfiguration.Configuration.DependencyResolver = AutofacBootStrapper.AutofacWebApiDependencyResolver(); // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }
public static void Register(HttpConfiguration config) { RaygunWebApiClient.Attach(config); HttpServer server = new HttpServer(config); config.Routes.MapHttpBatchRoute( routeName: "batch", routeTemplate: "api/batch", batchHandler: new DefaultHttpBatchHandler(new BatchServer(config))); // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(config => { RaygunWebApiClient.Attach(config); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); var jsonFormatter = config.Formatters.JsonFormatter; jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.AddJsonpFormatter(); // gives javascript error on t1 }); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
public static void Register() { // Use this class to set configuration options for your mobile service ConfigOptions options = new ConfigOptions(); options.LoginProviders.Remove(typeof(FacebookLoginProvider)); options.LoginProviders.Add(typeof(CustomFacebookLoginProvider)); // Use this class to set WebAPI configuration options HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options)); // To display errors in the browser during development, uncomment the following // line. Comment it out again when you deploy your service for production use. // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; // Set default and null value handling to "Include" for Json Serializer config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include; config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Include; Database.SetInitializer(new beerdrinkingtestInitializer()); RaygunWebApiClient.Attach(config); }
public static void Register(HttpConfiguration config, string raygunApiKey) { config.Filters.Add(new DeaggregateExceptionFilterAttribute()); config.Filters.Add(new ShipHubAuthenticationAttribute()); config.Filters.Add(new AuthorizeAttribute()); config.Filters.Add(new CommonLogActionFilterAttribute()); RaygunWebApiClient.Attach(config, RaygunClientFactory(raygunApiKey)); config.Formatters.Clear(); config.Formatters.Add(new ChunkedJsonMediaTypeFormatter() { SerializerSettings = JsonUtility.JsonSerializerSettings }); config.EnableCors(); config.MapHttpAttributeRoutes(); // Application Insights exception logging config.Services.Add(typeof(IExceptionLogger), new ApplicationInsightsExceptionLogger()); // Common logging for exceptions config.Services.Add(typeof(IExceptionLogger), new CommonLogExceptionLogger()); }