Update release script to build/distribute backend
This commit is contained in:
@ -1,8 +1,12 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"path"
|
||||
|
||||
"forge.cadoles.com/wpetit/guesstimate/internal/config"
|
||||
"github.com/go-chi/chi"
|
||||
"gitlab.com/wpetit/goweb/static"
|
||||
)
|
||||
|
||||
func Mount(r *chi.Mux, config *config.Config) error {
|
||||
@ -13,5 +17,16 @@ func Mount(r *chi.Mux, config *config.Config) error {
|
||||
r.Delete("/projects/{projectID}", handleDeleteProject)
|
||||
})
|
||||
|
||||
clientIndex := path.Join(config.HTTP.PublicDir, "index.html")
|
||||
|
||||
serveClientIndex := func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, clientIndex)
|
||||
}
|
||||
|
||||
r.Get("/p/*", serveClientIndex)
|
||||
|
||||
notFoundHandler := r.NotFoundHandler()
|
||||
r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user