コード例 #1
0
        public void Configuration(IAppBuilder app)
        {
            LogConfigurator.ConfigureForWeb(Assembly.GetExecutingAssembly().GetName().Name);

            Log.Information("Application_Start");

            ConfigureSecurity(app);

            app.UseSwaggerUi3(new[] { typeof(ExternalController) }, settings =>
            {
                settings.GeneratorSettings.DefaultUrlTemplate = "api/{controller}/{action}/{id?}";
                settings.GeneratorSettings.Title       = "Viaduc REST API";
                settings.GeneratorSettings.Description = @"The API lets you search the Swiss Federal Archives.";
                settings.GeneratorSettings.Version     = "1.0";
                settings.PostProcess = doc =>
                {
                    doc.Servers.Clear();
                    doc.Servers.Add(new OpenApiServer
                    {
                        // Basis-URL der Doku auf BAR-Umgebungen stimmen sonst nicht
                        Url = WebHelper.SwaggerBaseUrl
                    });
                };
                settings.GeneratorSettings.SerializerSettings = new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                };
            }, new SwaggerJsonSchemaGenerator(new JsonSchemaGeneratorSettings()));


            BusConfig.Configure(NinjectWebCommon.Kernel);
            AreaRegistration.RegisterAllAreas();

            GlobalConfiguration.Configure(cfg =>
            {
                cfg.Services.Add(typeof(IExceptionLogger), new CustomExceptionLogger());
                cfg.Services.Replace(typeof(IExceptionHandler), new CustomExceptionHandler());
                WebApiConfig.Register(cfg);
            });

            WebConfig.Configure();
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            RoutingHelper.Initialize();
        }
コード例 #2
0
        private static void RegisterDependencyResolver()
        {
            var builder = new ContainerBuilder();

            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.RegisterWebApiModelBinderProvider();

            builder.RegisterBus();
            builder.RegisterFrontendInjectables();

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);

            BusConfig.StartBus(container);
        }