strip "assets" from embedded fs

This commit is contained in:
Aaron Bieber 2023-05-18 13:03:47 -06:00
parent a434afeee9
commit b221582a13
No known key found for this signature in database

10
main.go
View File

@ -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)