// HTTP Server Benchmark
//
// A minimal HTTP server for benchmarking request throughput.
// Run with: lux benchmarks/http_benchmark.lux
//
// Test with:
//   wrk -t4 -c100 -d10s http://localhost:8080/
//   OR
//   ab -n 10000 -c 100 http://localhost:8080/
//
// Expected: > 50k req/sec on modern hardware

fn handleRequest(request: { method: String, path: String, body: String }): { status: Int, body: String } with {Console} = {
    // Minimal JSON response for benchmarking
    { status: 200, body: "{\"status\":\"ok\"}" }
}

fn serveLoop(): Unit with {Console, HttpServer} = {
    let request = HttpServer.accept()
    let response = handleRequest(request)
    HttpServer.respond(response.status, response.body)
    serveLoop()
}

fn main(): Unit with {Console, HttpServer} = {
    Console.print("HTTP Benchmark Server")
    Console.print("Listening on port 8080...")
    Console.print("")
    Console.print("Test with:")
    Console.print("  wrk -t4 -c100 -d10s http://localhost:8080/")
    Console.print("  ab -n 10000 -c 100 http://localhost:8080/")
    Console.print("")
    HttpServer.listen(8080)
    serveLoop()
}

let result = run main() with {}
