package routes import ( "io/fs" "net/http" ) // Route describes an API endpoint. type Route struct { Pattern string Handler http.Handler ReqType any ResType any } // HTTP creates a raw HTTP handler route. func HTTP(pattern string, handler http.HandlerFunc) Route { return Route{ Pattern: pattern, Handler: handler, } } // Register registers routes with the router. func Register(mux *http.ServeMux, routes []Route) { for _, route := range routes { mux.Handle(route.Pattern, route.Handler) } } func Static(mux *http.ServeMux, filesys fs.FS, pattern, filepath string) { mux.HandleFunc(pattern, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { http.ServeFileFS(w, r, filesys, filepath) })) }