gitoria
All repositories: gitoria
775 B
// api.hl — the JSON/Markdown API's plumbing. Statics only; the routes are in project.hl.import { Response } from 'hl:http1'static jsonHeaders = { 'Content-Type' = 'application/json; charset=utf-8' }static reply = (status, value) => {return new Response(JSON.stringify(value), { status = status headers = jsonHeaders })}static fail = (status, message) => { return reply(status, { error = message }) }// THE MARKDOWN READ VIEW: `Accept: text/markdown` (for LLM readers)static wantsMarkdown = (req) => {let a = req.headers['accept']return a != null && hlTypeName(a) == 'String' && a.includes('text/markdown')}static markdownReply = (text) => {return new Response(text, { status = 200 headers = { 'Content-Type' = 'text/markdown; charset=utf-8' } })}
Branches
- mainmain branch