Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ async fn fetch(request: Request, env: Env, _ctx: Context) -> worker::Result<Resp
match request.path().as_str() {
"/health" => Response::ok(r#"{"ready":true}"#).map(json),
"/" if request.method() == worker::Method::Get => {
let expected = env.secret("STATUS_TOKEN")?.to_string();
let provided = request
.headers()
.get("Authorization")?
.and_then(|header| header.strip_prefix("Bearer ").map(str::to_string));
if provided.as_deref() != Some(expected.as_str()) {
return Response::error("Unauthorized", 401);
}
let rpc: JsValue = world(&env)?.into();
let status = method(&rpc, "status", &[])?;
let status =
Expand Down