// 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(); }
static void Main(string[] args) { Console.WriteLine("Hello client!"); var token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NTI1ODM4NjUsInVzZXJuYW1lIjoiYWRtaW4iLCJkZXBhcnRtZW50IjoiSVTpg6gifQ.tx4etoJenyjsujHP5QGwSlhgyl9n2ftn-UziyGIIDPo"; var container = new ContainerBuilder(); var host = new ApplicationClientBuilder(container) //.UseLog4netLogger(new JimuLog4netOptions { EnableConsoleLog = true }) //.UsePollingAddressSelector() //.UseConsulForDiscovery(new Jimu.Client.Discovery.ConsulIntegration.ConsulOptions("127.0.0.1", 8500, "JimuService-")) //.UseHttpForTransfer() //.UseDotNettyForTransfer() .UseToken(() => token) //.UseServiceProxy(new Jimu.Client.Proxy.ServiceProxyOptions( new[] { "IServices" })) .Build(); host.Run(); Stopwatch watch = new Stopwatch(); while (Console.ReadLine() != "exit") { watch.Reset(); watch.Start(); var proxy = host.Container.Resolve <IServiceProxy>(); var echo = proxy.GetService <IEchoService>(); var name = echo.GetEcho("test"); watch.Stop(); Console.WriteLine($"take time {watch.ElapsedMilliseconds}," + "return: " + name); } Console.ReadKey(); }
// 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(); }
// 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(); } app.UseJimuSwagger(); // jimu client var host = new ApplicationClientBuilder(new ContainerBuilder()).Build(); app.UseJimu(host); host.Run(); }
// 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) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // start jimu client host; var host = new ApplicationClientBuilder(new ContainerBuilder()) //.UseConsulForDiscovery(new Jimu.Client.Discovery.ConsulIntegration.ConsulOptions("127.0.0.1", 8500, "JimuService-")) //.UseDotNettyForTransfer() //.UseHttpForTransfer() //.UsePollingAddressSelector() .Build(); app.UseJimu(host); host.Run(); }