mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Add docker file
This commit is contained in:
@@ -77,15 +77,23 @@ export async function handler(req: Request, ctx: MiddlewareHandlerContext) {
|
||||
}
|
||||
if (url.pathname == "/flutter" || url.pathname.startsWith("/flutter/")) {
|
||||
const m = get_task_manager();
|
||||
let flutter_base = import.meta.resolve("../static/flutter").slice(7);
|
||||
if (Deno.build.os === "windows") {
|
||||
flutter_base = flutter_base.slice(1);
|
||||
}
|
||||
if (!m.cfg.flutter_frontend) {
|
||||
return new Response("Flutter frontend is not enabled", {
|
||||
status: 404,
|
||||
});
|
||||
if (!await exists(flutter_base)) {
|
||||
return new Response("Flutter frontend is not enabled", {
|
||||
status: 404,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
flutter_base = m.cfg.flutter_frontend;
|
||||
}
|
||||
const u = new URL(req.url);
|
||||
let p = join(m.cfg.flutter_frontend, u.pathname.slice(8));
|
||||
if (!(await exists(p)) || p === m.cfg.flutter_frontend) {
|
||||
p = join(m.cfg.flutter_frontend, "/index.html");
|
||||
let p = join(flutter_base, u.pathname.slice(8));
|
||||
if (!(await exists(p)) || p === flutter_base) {
|
||||
p = join(flutter_base, "/index.html");
|
||||
}
|
||||
const opts: GetFileResponseOptions = {};
|
||||
opts.range = req.headers.get("range");
|
||||
|
||||
@@ -19,6 +19,7 @@ function handle_auth(req: Request, ctx: MiddlewareHandlerContext) {
|
||||
const check = () => {
|
||||
if (u.pathname === "/api/token" && req.method === "PUT") return true;
|
||||
if (u.pathname === "/api/status" && req.method === "GET") return true;
|
||||
if (u.pathname === "/api/health_check" && req.method === "GET") return true;
|
||||
return false;
|
||||
};
|
||||
if (!token) return check();
|
||||
|
||||
7
routes/api/health_check.ts
Normal file
7
routes/api/health_check.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(_req, _ctx) {
|
||||
return new Response("OK");
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user