Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.3 kB ยท 39 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940import { withPoweredBy } from "../../content/markdown";import { markdownCacheControl } from "../proxy/markdown-cache-control";import { computeETag, isNotModified } from "./etag";
const MARKDOWN = "text/markdown; charset=utf-8";
export interface MarkdownResponseInit { body: string; source: string | null; whiteLabel: boolean; accessType: string | null | undefined;}
export interface ResolvedMarkdownResponse { status: number; body: string | null; headers: Record<string, string>;}
// Pure response shaping: append the powered-by footer, hash a strong ETag, and// return a 304 (null body) when If-None-Match matches. `Vary: Accept` always โ// the same URL serves HTML or markdown by negotiation, so caches must split.export function resolveMarkdownResponse( request: Request, { body, source, whiteLabel, accessType }: MarkdownResponseInit,): ResolvedMarkdownResponse { const finalBody = withPoweredBy(body, whiteLabel); const etag = computeETag(finalBody); const headers = { "Content-Type": MARKDOWN, "Cache-Control": markdownCacheControl(source, accessType), ETag: etag, Vary: "Accept", }; if (isNotModified(request, etag)) { return { status: 304, body: null, headers }; } return { status: 200, body: finalBody, headers };}