public IActionResult RegisterToConsul() { ConsulServicesHelper.RegisterToConsul(consulIP, consulPort, "127.0.0.1", 5000, "TestServiceName", "http://127.0.0.1:5000/api/Consul/HealthCheck", TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10), _appLifetime); return(Ok()); }
/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app"></param> /// <param name="env"></param> /// <param name="appLifetime"></param> public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); //认证 app.UseAuthentication(); //授权 app.UseAuthorization(); //swagger app.UseTdbSwagger(); app.UseTdbSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1 Docs"); c.DocExpansion(DocExpansion.None); }); //httpreports app.UseHttpReports(); //本地服务URI var localUri = new Uri(AccConfig.App.ApiUrl); //注册consul ConsulServicesHelper.RegisterToConsul( AccConfig.App.Consul.IP, AccConfig.App.Consul.Port, localUri.Host, localUri.Port, AccConfig.App.Consul.ServiceCode, $"{AccConfig.App.ApiUrl}/tdbaccount/Sys/HealthCheck",//"http://10.1.49.45:5000/api/Consul/HealthCheck", TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(30), appLifetime); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }