strip "assets" from embedded fs
This commit is contained in:
parent
a434afeee9
commit
b221582a13
10
main.go
10
main.go
@ -8,6 +8,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -107,12 +108,15 @@ func main() {
|
|||||||
r.Use(middleware.Logger)
|
r.Use(middleware.Logger)
|
||||||
r.Use(OwnerCtx)
|
r.Use(OwnerCtx)
|
||||||
|
|
||||||
|
var liveServer http.Handler
|
||||||
if *dev {
|
if *dev {
|
||||||
liveServer := http.FileServer(http.Dir("./assets"))
|
liveServer = http.FileServer(http.Dir("./assets"))
|
||||||
r.Mount("/", liveServer)
|
|
||||||
} else {
|
} else {
|
||||||
r.Mount("/", http.FileServer(http.FS(assets)))
|
embFS, _ := fs.Sub(assets, "assets")
|
||||||
|
liveServer = http.FileServer(http.FS(embFS))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.Mount("/", liveServer)
|
||||||
r.Route("/pullrequests", func(r chi.Router) {
|
r.Route("/pullrequests", func(r chi.Router) {
|
||||||
r.Use(render.SetContentType(render.ContentTypeJSON))
|
r.Use(render.SetContentType(render.ContentTypeJSON))
|
||||||
r.Get("/", pullrequestsGET)
|
r.Get("/", pullrequestsGET)
|
||||||
|
Loading…
Reference in New Issue
Block a user