Fix SSE architecture for reliable connections (#13)
This commit was merged in pull request #13.
This commit is contained in:
22
assets/static_dev.go
Normal file
22
assets/static_dev.go
Normal file
@@ -0,0 +1,22 @@
|
||||
//go:build dev
|
||||
|
||||
package assets
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func Handler() http.Handler {
|
||||
log.Debug().Str("path", DirectoryPath).Msg("static assets served from filesystem")
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
http.StripPrefix("/assets/", http.FileServerFS(os.DirFS(DirectoryPath))).ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func StaticPath(path string) string {
|
||||
return "/assets/" + path
|
||||
}
|
||||
Reference in New Issue
Block a user