Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
app.Use(async (context, func) =>
{
if (context.Request.Path.Value == "/hc")
{
try
{
using (var db = new SqlConnection("Database=Oops"))
{
await db.OpenAsync();
db.Close();
}
context.Response.StatusCode = 200;
context.Response.ContentLength = 2;
await context.Response.WriteAsync("UP");
}
catch (SqlException)
{
context.Response.StatusCode = 400;
context.Response.ContentLength = 20;
await context.Response.WriteAsync("SQL Connection Error");
}
}
else
{
await func.Invoke();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment