Пример #1
0
        public static void ConfigureHealthCheck(this IServiceCollection services, IConfiguration configuration)
        {
            var connString = configuration.GetConnectionString("DefaultConnectionString");

            services.AddHealthChecks()
            .AddCheck("Db Health", () => HealthCheckProvider.CheckDb(connString));
        }
Пример #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

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

                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Hello World!");
                });
                endpoints.MapHealthChecks("health", new HealthCheckOptions()
                {
                    ResponseWriter = HealthCheckProvider.GetInstance(env).WriteHealthStatusAsJson
                });
            });
        }
        private static void OnCallBack()
        {
            var healthcheckprovider = HealthCheckProvider.Check(address);

            WriteHealthCheckData(healthcheckprovider);
        }