WIP: routing
This commit is contained in:
parent
c669e99694
commit
3a8f293144
@ -3,6 +3,7 @@ FROM openresty/openresty:1.27.1.2-0-bookworm-buildpack
|
|||||||
WORKDIR /opt/app
|
WORKDIR /opt/app
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y python3-pygments pandoc lua-inotify
|
RUN apt-get update && apt-get install -y python3-pygments pandoc lua-inotify
|
||||||
|
RUN opm get DevonStrawn/lua-resty-route
|
||||||
RUN luarocks install sitegen
|
RUN luarocks install sitegen
|
||||||
RUN luarocks install inotify INOTIFY_INCDIR=/usr/include/x86_64-linux-gnu/
|
RUN luarocks install inotify INOTIFY_INCDIR=/usr/include/x86_64-linux-gnu/
|
||||||
|
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
worker_processes 1;
|
worker_processes 1;
|
||||||
error_log logs/error.log;
|
error_log logs/error.log;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
|
init_by_lua_block {
|
||||||
|
require "routes"
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 8080;
|
listen 8080;
|
||||||
|
|
||||||
@ -12,9 +18,15 @@ http {
|
|||||||
|
|
||||||
location / {
|
location / {
|
||||||
default_type text/html;
|
default_type text/html;
|
||||||
# content_by_lua_block {
|
}
|
||||||
# ngx.say("<p>hello, world</p>")
|
|
||||||
# }
|
location /foo {
|
||||||
|
default_type text/html;
|
||||||
|
|
||||||
|
rewrite_by_lua_block {
|
||||||
|
routes = require "routes"
|
||||||
|
routes:dispatch()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
location /css {
|
location /css {
|
||||||
|
6
routes.lua
Normal file
6
routes.lua
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
local route = require("resty.route").new()
|
||||||
|
route:get("/foo", function(self)
|
||||||
|
local uri = "/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html"
|
||||||
|
return ngx.req.set_uri(uri, true)
|
||||||
|
end)
|
||||||
|
return route
|
7
routes.moon
Normal file
7
routes.moon
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
route = require("resty.route").new!
|
||||||
|
|
||||||
|
route\get "/foo", =>
|
||||||
|
uri = "/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html"
|
||||||
|
ngx.req.set_uri(uri, true)
|
||||||
|
|
||||||
|
route
|
Loading…
x
Reference in New Issue
Block a user