// src/web/router.gleam
import gleam/http.{Get, Post}
import web/handlers/job_handler
import wisp.{type Request, type Response}
pub fn handle_request(req: Request) -> Response {
use <- wisp.log_request(req)
use <- wisp.rescue_crashes
use req <- wisp.handle_head(req)
// Serve static files first, including index.html for root
use <- wisp.serve_static(req, under: "/", from: "public/static")
case wisp.path_segments(req) {
// API endpoints
["api", "v1", "jobs"] ->
case req.method {
Post -> job_handler.submit_job(req)
_ -> wisp.method_not_allowed([Post])
}
// Health check
["health"] ->
case req.method {
Get -> wisp.ok() |> wisp.string_body("OK")
_ -> wisp.method_not_allowed([Get])
}
// 404 for unmatched paths
_ -> wisp.not_found()
}
}
as you can wisp has a method of serving file. I am able to index.html from the public directory so someone can see localhost:8080/index.html. I wish there was a way where I could just set the default localhost:8080 to serve the file. I imagine the answer could be simple so if you could point me to function in wisp that could help, I would appreciate or you could confirm it's impossible that would helpful too