import { Handlers } from "$fresh/server.ts"; import { get_pages_meta } from "../../../pages.ts"; import { Status, STATUS_TEXT } from "https://deno.land/std@0.195.0/http/mod.ts"; export const handler: Handlers = { async GET(req, _ctx): Promise { const headers = new Headers({ "content-type": "application/json" }); const [body, mtime] = await get_pages_meta(); headers.set("last-modified", new Date(mtime).toUTCString()); console.log("aaa"); const ifModifiedSinceValue = req.headers.get("if-modified-since"); if ( ifModifiedSinceValue && mtime != new Date(ifModifiedSinceValue).getTime() ){ return new Response(null, { status: Status.NotModified, statusText: STATUS_TEXT[Status.NotModified] }) } return new Response(JSON.stringify(body), {headers}); }, };