chore: cleanup sprint — dead CSS, dedup helpers, handler refactor
Remove ~126 lines of orphaned CSS from tile slim-down and old detail layout. Consolidate 4 duplicate duration formatters into shared elapsed()/fmtElapsed() helpers. Break 160-line Result handler into focused sub-functions. Implement real Hub.Shutdown() (was a no-op). Standardize agent error responses to JSON. Replace panic() in router init with error return. Extract magic numbers as named constants. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package httpserver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
|
||||
@@ -21,7 +22,7 @@ type Deps struct {
|
||||
AgentAssetDir string // directory containing vetting-agent-linux-amd64; "" disables /assets
|
||||
}
|
||||
|
||||
func NewRouter(d Deps) http.Handler {
|
||||
func NewRouter(d Deps) (http.Handler, error) {
|
||||
r := chi.NewRouter()
|
||||
r.Use(middleware.RealIP)
|
||||
r.Use(middleware.Recoverer)
|
||||
@@ -29,7 +30,7 @@ func NewRouter(d Deps) http.Handler {
|
||||
|
||||
staticFS, err := fs.Sub(web.Static, "static")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, fmt.Errorf("extract static assets: %w", err)
|
||||
}
|
||||
r.Handle("/static/*", http.StripPrefix("/static/", http.FileServer(http.FS(staticFS))))
|
||||
|
||||
@@ -80,5 +81,5 @@ func NewRouter(d Deps) http.Handler {
|
||||
r.Get("/register/quick.sh", d.UI.QuickRegisterScript)
|
||||
r.Get("/events", d.UI.SSE)
|
||||
|
||||
return r
|
||||
return r, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user