lets-go:13.1 embed static
This commit is contained in:
parent
ba6bf1a682
commit
ba4f38b425
@ -5,6 +5,8 @@ import (
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/justinas/alice"
|
||||
|
||||
"snippetbox.chaosfem.tw/ui"
|
||||
)
|
||||
|
||||
// routes ...
|
||||
@ -20,8 +22,8 @@ func (app *application) routes() http.Handler {
|
||||
})
|
||||
|
||||
// setup server for static files
|
||||
fileServer := http.FileServer(http.Dir("./ui/static"))
|
||||
router.Handler(http.MethodGet, "/static/*filepath", http.StripPrefix("/static", fileServer))
|
||||
fileServer := http.FileServer(http.FS(ui.Files))
|
||||
router.Handler(http.MethodGet, "/static/*filepath", fileServer)
|
||||
|
||||
dynamic := alice.New(app.sessionManager.LoadAndSave, noSurf, app.authenticate)
|
||||
|
||||
|
8
snippetbox/ui/efs.go
Normal file
8
snippetbox/ui/efs.go
Normal file
@ -0,0 +1,8 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"embed"
|
||||
)
|
||||
|
||||
//go:embed "static"
|
||||
var Files embed.FS
|
Loading…
Reference in New Issue
Block a user