Add docker file

This commit is contained in:
2024-01-21 11:30:02 +08:00
parent c0d86d3da5
commit b8b1192d88
8 changed files with 133 additions and 35 deletions

View File

@@ -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");

View File

@@ -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();

View File

@@ -0,0 +1,7 @@
import { Handlers } from "$fresh/server.ts";
export const handler: Handlers = {
GET(_req, _ctx) {
return new Response("OK");
},
};