Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created June 28, 2018 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/3a903f38da86aff49bbaa1f40fe7da97 to your computer and use it in GitHub Desktop.
Save dcomartin/3a903f38da86aff49bbaa1f40fe7da97 to your computer and use it in GitHub Desktop.
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