20 lines
414 B
Go
20 lines
414 B
Go
package ui
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
const StaticRoute = "/static/"
|
|
|
|
type StaticController struct {
|
|
staticDir string
|
|
}
|
|
|
|
func NewStaticController(staticDir string) *StaticController {
|
|
return &StaticController{staticDir: staticDir}
|
|
}
|
|
|
|
func (sc *StaticController) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
fs := http.FileServer(http.Dir(sc.staticDir))
|
|
http.StripPrefix(StaticRoute, fs).ServeHTTP(w, r)
|
|
}
|