mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Add teapot to example
This commit is contained in:
parent
5f831ebb9f
commit
43713fbe92
1 changed files with 10 additions and 3 deletions
|
@ -7,9 +7,14 @@ local PORT = if process.env.PORT ~= nil and #process.env.PORT > 0
|
||||||
|
|
||||||
-- Create our responder functions
|
-- Create our responder functions
|
||||||
|
|
||||||
local function pong(request: NetRequest): NetResponse
|
local function pong(request: NetRequest): string
|
||||||
|
return `Pong!\n{request.path}\n{request.body}`
|
||||||
|
end
|
||||||
|
|
||||||
|
local function teapot(request: NetRequest): NetResponse
|
||||||
return {
|
return {
|
||||||
body = `Pong!\n{request.path}\n{request.body}`,
|
status = 418,
|
||||||
|
body = "🫖",
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,8 +38,10 @@ end)
|
||||||
|
|
||||||
print(`Listening on port {PORT} 🚀`)
|
print(`Listening on port {PORT} 🚀`)
|
||||||
net.serve(PORT, function(request)
|
net.serve(PORT, function(request)
|
||||||
if string.sub(request.path, 1, 6) == "/ping" then
|
if string.sub(request.path, 1, 5) == "/ping" then
|
||||||
return pong(request)
|
return pong(request)
|
||||||
|
elseif string.sub(request.path, 1, 7) == "/teapot" then
|
||||||
|
return teapot(request)
|
||||||
else
|
else
|
||||||
return notFound(request)
|
return notFound(request)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue