Created
June 28, 2018 20:55
-
-
Save dcomartin/3a903f38da86aff49bbaa1f40fe7da97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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