WIP: routes???

This commit is contained in:
2025-05-18 14:46:15 -07:00
parent 6a634ceea3
commit 8a92d0451b
3 changed files with 79 additions and 14 deletions

View File

@@ -16,22 +16,39 @@ http {
include mime.types;
charset utf-8;
location / {
default_type text/html;
location = /posts {
# rewrite ^ /posts/ last; # loads "/posts/"
# rewrite ^ /posts/ break; # loads "/posts/index.html"
rewrite_by_lua_block {
-- equivalent to `rewrite ^ /posts/ break;`
ngx.req.set_uri("/posts/", false)
}
}
location /foo {
default_type text/html;
rewrite_by_lua_block {
routes = require "routes"
routes:dispatch()
location = /posts/ {
content_by_lua_block {
return ngx.redirect("/posts", ngx.HTTP_MOVED_PERMANENTLY)
}
}
location /posts/ {
content_by_lua_block {
require "routes":dispatch()
-- ngx.req.set_uri("/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html")
-- ngx.req.set_uri(ngx.var.uri, false)
-- ngx.req.set_uri("/posts/index.html", false)
}
# rewrite ^ /posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html break;
}
location /css {
expires 1h;
alias css;
}
location /blah {
rewrite ^/posts$ /posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html break;
}
}
}