http-boot-server/bootserver/controllers/ui/static.go

21 lines
414 B
Go
Raw Normal View History

2023-08-16 21:33:26 +00:00
package ui
import (
"net/http"
)
const StaticRoute = "/static/"
type StaticController struct {
staticDir string
}
func NewStaticController(staticDir string) *StaticController {
return &StaticController{staticDir: staticDir}
2023-08-16 21:33:26 +00:00
}
func (sc *StaticController) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fs := http.FileServer(http.Dir(sc.staticDir))
2023-08-16 21:33:26 +00:00
http.StripPrefix(StaticRoute, fs).ServeHTTP(w, r)
}