diff options
Diffstat (limited to 'reluax.luax')
| -rw-r--r-- | reluax.luax | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/reluax.luax b/reluax.luax index cb45ae6..034d408 100644 --- a/reluax.luax +++ b/reluax.luax @@ -15,7 +15,12 @@ local blogposts = require("blog.posts") math.randomseed(os.time()) -local function wrap_component(component) +local redirects = { + { slug = "mrfinalboss", url = "https://jellingfish-games.itch.io/mr-final-boss" }, + { slug = "bumblingbuilders", url = "https://oroshibu.itch.io/bumbling-builders" } +} + +local wrap_component = function(component) return <Common> <Navbar /> @@ -28,8 +33,28 @@ local function wrap_component(component) </Common> end -local function route(path) - if path == '/' then +local route = function(path, method, headers, body) + if method ~= 'GET' then + return 405, "Method not allowed" + end + + if reluax.url_matches('/r/{slug}', path) then + local slug = reluax.url_extract('/r/{slug}', path).slug + local redirect = nil + for _, r in ipairs(redirects) do + if r.slug == slug then + redirect = r + break + end + end + if redirect then + local headers = { + ["Location"] = redirect.url + } + local body = <a>You are being redirected...</a> + return 301, reluax.headers(body, headers) + end + elseif path == '/' then return 200, wrap_component(<Home />) elseif path == '/projects' then return 200, wrap_component(<Projects />) |
