Esempio n. 1
0
        public void Configure(IApplicationBuilder app)
        {
            ApiConfiguration.Configure(app);

            app.UseAuthentication();

            app.UseMvc();
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            ApiConfiguration.Configure(app);

            app.UseStaticFiles()
            .UseAuthentication()
            .UseMvc();
        }
Esempio n. 3
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IConfiguration>(_configuration);

            services.AddMvc();
            services.AddMemoryCache();

            ApiConfiguration.Configure(services);
        }
Esempio n. 4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            ApiConfiguration.Configure(app);
        }
Esempio n. 5
0
        public void Configure(IApplicationBuilder app)
        {
            ApiConfiguration.Configure(app, host =>
            {
                host.UseAuthentication();

                return(host);
            });
        }
Esempio n. 6
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer();

            services.AddControllers()
            .AddApplicationPart(Assembly.Load(new AssemblyName("Sample.Api")));

            ApiConfiguration.Configure(services);
        }
Esempio n. 7
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseCors(AllowedOrigins)
            .UseUnitOfWork();

            ApiConfiguration.Configure(app, host =>
            {
                host.UseOpenApi();

                return(host);
            });
        }
Esempio n. 8
0
 public void Configure(
     IApplicationBuilder app,
     IWebHostEnvironment env,
     IApiVersionDescriptionProvider apiVersion)
 {
     ApiConfiguration.Configure(
         app,
         preConfigure: pre => pre
         .AddIf(env.IsDevelopment(), x => x.UseDeveloperExceptionPage())
         .UseOpenApi(apiVersion),
         postConfigure: post => post);
 }
Esempio n. 9
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     else
     {
         app.UseExceptionHandler("/Home/Error");
     }
     ApiConfiguration.Configure(app, provider);
 }
Esempio n. 10
0
        private static HttpConfiguration BuidHttpConfiguration(IContainer container)
        {
            // Create HttpConfiguration
            var config = new HttpConfiguration
            {
                DependencyResolver = new AutofacWebApiDependencyResolver(container)
            };

            // Configure common options
            ApiConfiguration.Configure(config);

            // Overriden configurations
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            return(config);
        }
Esempio n. 11
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
 {
     ApiConfiguration.Configure(app, host => host
                                .UseIf(env.IsDevelopment(), appBuilder => appBuilder.UseDeveloperExceptionPage())
                                .UseSwagger()
                                .UseIf(env.IsDevelopment(), appBuilder => appBuilder.UseSwaggerUI(setup => {
         setup.SwaggerEndpoint("/swagger/v1/swagger.json", nameof(TrisvagoHotels));
     }))
                                .UseHttpsRedirection()
                                .UseCustomHealthchecks()
                                .UseRouting()
                                .UseCors("CorsApi")
                                .UseHeaderDiagnostics()
                                .UseHealthChecksUI()
                                .UseResponseCompression()
                                );
 }
Esempio n. 12
0
        private static HttpConfiguration BuidHttpConfiguration(IContainer container, IAppBuilder app)
        {
            // Create HttpConfiguration
            var config = new HttpConfiguration
            {
                DependencyResolver = new AutofacWebApiDependencyResolver(container)
            };

            // Add policy based authorization
            app.UseAuthorization(Policies.Configure);

            // Configure common options
            ApiConfiguration.Configure(config);

            // Overriden configurations
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            return(config);
        }
        /// TODO GitHubIssue#51 : Support model lazy loading
        /// <summary>
        /// Maps the API routes to the RestierController.
        /// </summary>
        /// <typeparam name="TApi">The user API.</typeparam>
        /// <param name="config">The <see cref="HttpConfiguration"/> instance.</param>
        /// <param name="routeName">The name of the route.</param>
        /// <param name="routePrefix">The prefix of the route.</param>
        /// <param name="apiFactory">The callback to create API instances.</param>
        /// <param name="batchHandler">The handler for batch requests.</param>
        /// <returns>The task object containing the resulted <see cref="ODataRoute"/> instance.</returns>
        public static Task <ODataRoute> MapRestierRoute <TApi>(
            this HttpConfiguration config,
            string routeName,
            string routePrefix,
            Func <ApiBase> apiFactory,
            RestierBatchHandler batchHandler = null)
            where TApi : ApiBase
        {
            Ensure.NotNull(apiFactory, "apiFactory");

            // ApiBase.ConfigureApi is called before this method is called.
            ApiConfiguration.Configure <TApi>(services =>
            {
                services.AddScoped <RestierQueryExecutorOptions>()
                .ChainPrevious <IQueryExecutor, RestierQueryExecutor>();
            });
            using (var api = apiFactory())
            {
                var model = api.GetModelAsync().Result;

                var conventions = CreateRestierRoutingConventions(config, model, apiFactory);

                if (batchHandler != null && batchHandler.ApiFactory == null)
                {
                    batchHandler.ApiFactory = apiFactory;
                }

                var route = config.MapODataServiceRoute(
                    routeName, routePrefix, model, new DefaultODataPathHandler(), conventions, batchHandler);

                // Customized converter should be added in ConfigureApi as service
                var converter = api.Context.GetApiService <ODataPayloadValueConverter>();
                if (converter == null)
                {
                    converter = new RestierPayloadValueConverter();
                }

                model.SetPayloadValueConverter(converter);

                return(Task.FromResult(route));
            }
        }
Esempio n. 14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            ApiConfiguration.Configure(app, host =>
            {
                if (env.IsDevelopment())
                {
                    host.UseDeveloperExceptionPage();
                }
                else
                {
                    host.UseHsts();
                }

                host.UseHttpsRedirection();

                host.UseAuthentication();

                host.UseCors();
                host.UseStaticFiles();

                return(host);
            });
        }
Esempio n. 15
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app)
 {
     ApiConfiguration.Configure(app);
 }
Esempio n. 16
0
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
 {
     ApiConfiguration.Configure(app, env)
     .UseRouting()
     .UseEndpoints(endpoints => endpoints.MapControllers());
 }