From 56098880b8dc2f78e5cc9f4e060cf6718fd6f789 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 8 Nov 2023 07:36:48 +0100 Subject: Create /health handler --- bun.lockb | Bin 14725 -> 14725 bytes fly.toml | 4 +--- src/app.ts | 4 +++- static/health.txt | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 static/health.txt diff --git a/bun.lockb b/bun.lockb index b4d52ec..1cb7655 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/fly.toml b/fly.toml index 7e09b9b..039c968 100644 --- a/fly.toml +++ b/fly.toml @@ -26,6 +26,4 @@ primary_region = "ams" interval = "30s" method = "GET" timeout = "5s" - path = "/health.txt" - [http_service.checks.headers] - Host = "alanpearce.eu" + path = "/health" diff --git a/src/app.ts b/src/app.ts index 8ba2d8a..7250a62 100644 --- a/src/app.ts +++ b/src/app.ts @@ -145,7 +145,9 @@ export const server = { "http.user_agent": request.headers.get("user-agent"), }, }); - if ( + if (pathname === "/health") { + return new Response("OK", { status: 200 }); + } else if ( config.redirect_other_hostnames && request.headers.get("host") !== expectedHostURL.host ) { diff --git a/static/health.txt b/static/health.txt deleted file mode 100644 index d86bac9..0000000 --- a/static/health.txt +++ /dev/null @@ -1 +0,0 @@ -OK -- cgit 1.4.1