fileserver!
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
0e0af9afa5
commit
873fe3f7d9
|
@ -16,15 +16,13 @@ class Server
|
|||
@cq\wrap ->
|
||||
with conn
|
||||
_, ip = \peername!
|
||||
pid, uid, gid = \peerpid!, \peereid!
|
||||
request = \read "*l"
|
||||
\shutdown "r"
|
||||
u = url.parse request
|
||||
if u.path == ""
|
||||
u.path = "/"
|
||||
ctx =
|
||||
:ip
|
||||
:pid
|
||||
:uid
|
||||
:gid
|
||||
host: u.host
|
||||
path: u.path
|
||||
query: u.query
|
||||
|
|
20
mipha.moon
20
mipha.moon
|
@ -11,7 +11,25 @@ class ProxyRequestRefusedHandler
|
|||
conn\write "53 Proxy request refused \r\n"
|
||||
ln.log ctx, {status: 53}
|
||||
|
||||
with gemini.Server ProxyRequestRefusedHandler!
|
||||
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"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
# foo
|
|
@ -0,0 +1 @@
|
|||
# test
|
Loading…
Reference in New Issue