2023-08-16 21:33:26 +00:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
const StaticRoute = "/static/"
|
|
|
|
|
|
|
|
type StaticController struct {
|
2024-03-24 12:37:40 +00:00
|
|
|
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) {
|
2024-03-24 12:37:40 +00:00
|
|
|
fs := http.FileServer(http.Dir(sc.staticDir))
|
2023-08-16 21:33:26 +00:00
|
|
|
http.StripPrefix(StaticRoute, fs).ServeHTTP(w, r)
|
|
|
|
}
|