Esempio n. 1
0
        public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJimu(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, IApplication host)
        {
            Console.WriteLine();
            app.UseMiddleware <JimuHttpStatusCodeExceptionMiddleware>();
            //app.UseCors(builder =>
            //{
            //    builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
            //});

            var httpContextAccessor = app.ApplicationServices.GetRequiredService <IHttpContextAccessor>();

            JimuHttpContext.Configure(httpContextAccessor);
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}");
                routes.MapRoute(
                    name: "defaultApi",
                    template: "api/{controller}/{action}");
                routes.MapRoute(
                    "swagger",
                    "swagger/{*path}"
                    );
                routes.MapRoute(
                    "JimuPath",
                    "{*path:regex(^(?!swagger))}",
                    new { controller = "JimuServices", action = "JimuPath" });
            });

            JimuClient.Host = host;
            return(app);
        }
Esempio n. 2
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            Console.WriteLine();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });


            app.UseMiddleware <JimuHttpStatusCodeExceptionMiddleware>();
            //app.UseCors(builder =>
            //{
            //    builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
            //});

            var httpContextAccessor = app.ApplicationServices.GetRequiredService <IHttpContextAccessor>();

            JimuHttpContext.Configure(httpContextAccessor);
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}");
                routes.MapRoute(
                    name: "defaultApi",
                    template: "api/{controller}/{action}");
                routes.MapRoute(
                    "swagger",
                    "swagger/{*path}"
                    );
                routes.MapRoute(
                    "JimuPath",
                    "{*path:regex(^(?!swagger))}",
                    new { controller = "JimuServices", action = "JimuPath" });
            });
        }
Esempio n. 3
0
        public static IApplicationBuilder UseJimu(this IApplicationBuilder app, IApplication host)
        {
            var type       = typeof(ClientWebModuleBase);
            var webModules = AppDomain.CurrentDomain.GetAssemblies()
                             .SelectMany(x => x.GetTypes())
                             .Where(x => x.IsClass && type.IsAssignableFrom(x) && !x.IsAbstract)
                             .Select(x => Activator.CreateInstance(x, host.JimuAppSettings) as ClientWebModuleBase)
                             .OrderBy(x => x.Priority);

            app.UseMiddleware <JimuHttpStatusCodeExceptionMiddleware>();
            //app.UseCors(builder =>
            //{
            //    builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
            //});


            foreach (var configure in webModules)
            {
                configure.DoWebConfigure(app, host.Container);
            }

            var httpContextAccessor = app.ApplicationServices.GetRequiredService <IHttpContextAccessor>();

            JimuHttpContext.Configure(httpContextAccessor);
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}");
                routes.MapRoute(
                    name: "defaultApi",
                    template: "api/{controller}/{action}");
                routes.MapRoute(
                    "swagger",
                    "swagger/{*path}"
                    );
                routes.MapRoute(
                    "JimuPath",
                    "{*path:regex(^(?!swagger))}",
                    new { controller = "JimuServices", action = "JimuPath" });
            });

            JimuClient.Host = host;
            return(app);
        }