示例#1
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            // Enable swagger.
            app.UseStaticFiles();
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint(SwaggerConfig.GetEndpointUrl(), SwaggerConfig.DocInfoTitle);
                c.IndexStream = () => GetType().GetTypeInfo().Assembly.GetManifestResourceStream("DInTaskSchedulerApi.Application.Configurations.swagger-ui-custom.html");
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Enable CORS (Cross Origin Resource Sharing)
            app.UseCors(builder => builder
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());

            // Enable JWT (Json Web Token) authentication
            app.UseAuthentication();

            // Enable Mvc
            app.UseMvc();
        }