示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseCors("any");
            app.UseStaticFiles();
            app.UseAuthentication();

            if (env.IsDevelopment())
            {
                //app.UseDeveloperExceptionPage();
            }
            app.UseStatusCodePages();
            app.UseJimuSwagger();

            // jimu client

            Jimu.IApplication host;
#if DEBUG
            if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SERVICE_GROUPS")))
            {
                host = new ApplicationClientBuilder(new ContainerBuilder(), "JimuAppClientSettings.local").Build();
            }
            else
            {
                host = new ApplicationClientBuilder(new ContainerBuilder()).Build();
            }
#else
            host = new ApplicationClientBuilder(new ContainerBuilder()).Build();
#endif

            app.UseJimu(host);
            host.Run();
        }
示例#2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseStaticFiles();
            app.UseAuthentication();

            if (env.IsDevelopment())
            {
                //app.UseDeveloperExceptionPage();
            }
            app.UseStatusCodePages();
            app.UseJimuSwagger();

            // jimu client
            var host = new ApplicationClientBuilder(new ContainerBuilder())
                       //.UseLog4netLogger(new JimuLog4netOptions
                       ////.UseNLogger(new LogOptions
                       //{
                       //    EnableConsoleLog = true,
                       //    EnableFileLog = true,
                       //    FileLogLevel = LogLevel.Info | LogLevel.Error,
                       //})
                       //.UseConsulForDiscovery(new Client.Discovery.ConsulIntegration.ConsulOptions("127.0.0.1", 8500, "hello"))
                       //.UseDotNettyForTransfer()
                       //.UseHttpForTransfer()
                       //.UsePollingAddressSelector()
                       //.UseServerHealthCheck(1)
                       //.SetDiscoveryAutoUpdateJobInterval(new Client.Discovery.Implement.DiscoveryOptions(1))
                       //.UseToken(() => { var headers = JimuHttpContext.Current.Request.Headers["Authorization"]; return headers.Any() ? headers[0] : null; })
                       //.UseJoseJwtForOAuth<HttpAddress>(new Client.Auth.JwtAuthorizationOptions()
                       //{
                       //    ServerIp = "127.0.0.1",
                       //    ServerPort = 5001,
                       //    SecretKey = "test",
                       //    ExpireTimeSpan = new TimeSpan(1, 0, 0),
                       //    TokenEndpointPath = "/api/client/token",
                       //    ValidateLifetime = true,
                       //    CheckCredential = o =>
                       //    {
                       //        if (o.UserName == "admin" && o.Password == "admin")
                       //        {
                       //            o.AddClaim("department", "IT部");
                       //        }
                       //        else
                       //        {
                       //            o.Rejected("401", "acount or password incorrect");
                       //        }
                       //    }
                       //})
                       .Build();

            app.UseJimu(host);
            host.Run();
        }