perf: 静态路由修改为简单的map缓存

This commit is contained in:
meiseayoung
2025-12-29 12:14:20 +08:00
parent 7c1aa656ab
commit 3ef232a077
12 changed files with 990 additions and 404 deletions
+34
View File
@@ -0,0 +1,34 @@
// Minimal server example - Demonstrate Keep-Alive issue
module main
import net.http
import time
struct MyHandler {}
fn (_ MyHandler) handle(req http.Request) http.Response {
now := time.now()
println('[${now.format_ss_micro()}] Received request: ${req.method} ${req.url}')
return http.Response{
status_code: 200
status_msg: 'OK'
header: http.new_custom_header_from_map({
'Content-Type': 'text/plain'
'Connection': 'keep-alive' // Set but not effective
}) or { http.new_header() }
body: 'Hello! Time: ${now.format_ss_micro()}'
}
}
fn main() {
println('Starting server at http://localhost:8080')
println('Server sends Connection: keep-alive in response header')
println('But due to V stdlib limitation, connection is still closed')
mut server := http.Server{
handler: MyHandler{}
addr: ':8080'
}
server.listen_and_serve()
}