From 22ea459aaf6dcb3f41d45b3f2b307dba5d9c3833 Mon Sep 17 00:00:00 2001 From: Annwan Date: Sun, 11 Aug 2024 22:24:02 +0200 Subject: [PATCH] Add dispatch script --- main.lua | 15 +++++++++++++++ yqtemplate.lua | 6 ++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 main.lua diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..e930f59 --- /dev/null +++ b/main.lua @@ -0,0 +1,15 @@ +#!/usr/bin/env lua + +local fcgi = require"fcgi" +local yqtemplate = require"yqtemplate" + + +while fcgi.accept() do + app = fcgi.getenv("DOCUMENT_URI"):sub(6) + if app = "yqtemplate" then + yqtemplate(fcgi) + else + fcgi.print"Content-Type: text/plain; charset=utf-8\r\n\r\n" + fcgi.print("Unknown CGI application: `" .. app .. "'\n") + end +end diff --git a/yqtemplate.lua b/yqtemplate.lua index e1138ad..8166e72 100644 --- a/yqtemplate.lua +++ b/yqtemplate.lua @@ -1,5 +1,3 @@ -local fcgi = require"fcgi" -while fcgi.accept() do - fcgi.print("Content-Type: text/plain; charset=utf-8\r\n\r\n") - fcgi.print("Hello from" .. fcgi.getenv("DOCUMENT_URI") .. "\n") +return function(fcgi) + fcgi.print"Hello from application `YQTemplate'" end