adjust static file handling
This commit is contained in:
parent
1753007090
commit
e95f0f3370
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,3 +25,4 @@ go.work
|
||||
# Test directories and files
|
||||
test.lua
|
||||
test_fs_dir
|
||||
public
|
@ -72,12 +72,13 @@ local function match_route(method, path)
|
||||
return nil, {}
|
||||
end
|
||||
|
||||
-- Global handler function called by Go workers
|
||||
function _http_handle_request(req_table, res_table)
|
||||
local req = Request.new(req_table)
|
||||
local res = Response.new(res_table)
|
||||
|
||||
-- Find matching route
|
||||
-- Execute middleware chain first
|
||||
local function run_middleware(index)
|
||||
if index > #_G._http_middleware then
|
||||
local route, params = match_route(req.method, req.path)
|
||||
req.params = params
|
||||
|
||||
@ -86,10 +87,7 @@ function _http_handle_request(req_table, res_table)
|
||||
return
|
||||
end
|
||||
|
||||
-- Execute middleware chain
|
||||
local function run_middleware(index)
|
||||
if index > #_G._http_middleware then
|
||||
-- All middleware executed, run route handler
|
||||
-- Run route handler
|
||||
route.handler(req, res)
|
||||
return
|
||||
end
|
||||
@ -557,6 +555,7 @@ function http.static(root_path)
|
||||
[".jpeg"] = "image/jpeg",
|
||||
[".gif"] = "image/gif",
|
||||
[".svg"] = "image/svg+xml",
|
||||
[".webp"] = "image/webp",
|
||||
[".txt"] = "text/plain",
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user