hyper.quineglobal.com/http/static.go
2026-05-25 22:40:39 -07:00

15 lines
417 B
Go

package http
import (
"net/http"
"github.com/go-chi/chi/v5"
)
// Static assets handler, which serves files from the root that have an extension, and everything from
// the images, scripts, and styles directories.
func Static(r chi.Router) {
staticHandler := http.FileServer(http.Dir("public"))
r.Get(`/{:[^.]+\.[^.]+}`, staticHandler.ServeHTTP)
r.Get(`/{:images|scripts|styles}/*`, staticHandler.ServeHTTP)
}