webhookd/pkg/api/static.go
2020-09-11 11:48:18 +00:00

20 lines
436 B
Go

package api
import (
"net/http"
"github.com/ncarlier/webhookd/pkg/config"
)
func static(prefix string) HandlerFunc {
return func(conf *config.Config) http.Handler {
if conf.StaticDir != "" {
fs := http.FileServer(http.Dir(conf.StaticDir))
return http.StripPrefix(prefix, fs)
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "404 page not found", http.StatusNotFound)
})
}
}