cqueues = require "cqueues" socket = require "cqueues.socket" ln = require "ln" gemini = require "gemini" cq = cqueues.new! class ProxyRequestRefusedHandler serve: (ctx, conn) => conn\write "53 Proxy request refused \r\n" ln.log ctx, {status: 53} class FileServer serve: (ctx, conn) => fname = "./public" .. ctx.path ln.log ctx, :fname fin, err = io.open fname .. "/index.gmi" ln.err err, ctx if err != nil fin, err = io.open fname if err != nil conn\write "51 not found: " .. ctx.path .. "\r\n" conn\write "20 text/gemini\r\n" for line in fin\lines! conn\write line conn\flush! with gemini.Server FileServer! \listen socket.listen "127.0.0.1", "58816" \listen socket.listen path: "./var/mipha.sock" unlink: true \attach cq assert cq\loop!