Merge remote-tracking branch 'origin/master'
# Conflicts: # ui/src/pages/OrderList.vue
This commit is contained in:
36
svc/main.go
36
svc/main.go
@@ -12,7 +12,10 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
@@ -594,14 +597,13 @@ func main() {
|
|||||||
log.Fatal(http.ListenAndServe(":8080", handler))
|
log.Fatal(http.ListenAndServe(":8080", handler))
|
||||||
}
|
}
|
||||||
|
|
||||||
func mountSPA(m gorilla.Mux) {
|
func mountSPA(r *mux.Router) {
|
||||||
m.Group(func(r chi.Router) {
|
r.NotFoundHandler = http.HandlerFunc(spaIndex)
|
||||||
r.NotFound(spaIndex)
|
r.HandleFunc("/", spaIndex).Methods(http.MethodGet)
|
||||||
r.Get("/", spaIndex)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func spaIndex(w http.ResponseWriter, r *http.Request) {
|
func spaIndex(w http.ResponseWriter, r *http.Request) {
|
||||||
|
uiDir := uiRootDir()
|
||||||
p := r.URL.Path
|
p := r.URL.Path
|
||||||
|
|
||||||
if r.URL.Path == "/logo.png" {
|
if r.URL.Path == "/logo.png" {
|
||||||
@@ -626,20 +628,38 @@ func spaIndex(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
name := path.Join(app.RUN.UiDir, filepath.FromSlash(p))
|
name := path.Join(uiDir, filepath.FromSlash(p))
|
||||||
|
|
||||||
f, err := os.Stat(name)
|
f, err := os.Stat(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
http.ServeFile(w, r, fmt.Sprintf("%s/index.html", app.RUN.UiDir))
|
http.ServeFile(w, r, filepath.Join(uiDir, "index.html"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
http.Error(w, "internal server error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
Forbidden(w, nil)
|
http.Error(w, "forbidden", http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
http.ServeFile(w, r, name)
|
http.ServeFile(w, r, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func uiRootDir() string {
|
||||||
|
if d := strings.TrimSpace(os.Getenv("UI_DIR")); d != "" {
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
|
candidates := []string{"../ui/dist", "./ui/dist"}
|
||||||
|
for _, d := range candidates {
|
||||||
|
if fi, err := os.Stat(d); err == nil && fi.IsDir() {
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "../ui/dist"
|
||||||
|
}
|
||||||
|
|||||||
@@ -64,19 +64,19 @@
|
|||||||
"./../src/stores/*"
|
"./../src/stores/*"
|
||||||
],
|
],
|
||||||
"#q-app": [
|
"#q-app": [
|
||||||
"./../node_modules/.pnpm/@quasar+app-webpack@4.3.2_pinia@3.0.4_vue@3.5.20__quasar@2.18.6_sass@1.97.3_tslib@2.8.1_ea0679f3401f6e63bbfdc4dae8ab5531/node_modules/@quasar/app-webpack/types/index.d.ts"
|
"./../node_modules/@quasar/app-webpack/types/index.d.ts"
|
||||||
],
|
],
|
||||||
"#q-app/wrappers": [
|
"#q-app/wrappers": [
|
||||||
"./../node_modules/.pnpm/@quasar+app-webpack@4.3.2_pinia@3.0.4_vue@3.5.20__quasar@2.18.6_sass@1.97.3_tslib@2.8.1_ea0679f3401f6e63bbfdc4dae8ab5531/node_modules/@quasar/app-webpack/types/app-wrappers.d.ts"
|
"./../node_modules/@quasar/app-webpack/types/app-wrappers.d.ts"
|
||||||
],
|
],
|
||||||
"#q-app/bex/background": [
|
"#q-app/bex/background": [
|
||||||
"./../node_modules/.pnpm/@quasar+app-webpack@4.3.2_pinia@3.0.4_vue@3.5.20__quasar@2.18.6_sass@1.97.3_tslib@2.8.1_ea0679f3401f6e63bbfdc4dae8ab5531/node_modules/@quasar/app-webpack/types/bex/entrypoints/background.d.ts"
|
"./../node_modules/@quasar/app-webpack/types/bex/entrypoints/background.d.ts"
|
||||||
],
|
],
|
||||||
"#q-app/bex/content": [
|
"#q-app/bex/content": [
|
||||||
"./../node_modules/.pnpm/@quasar+app-webpack@4.3.2_pinia@3.0.4_vue@3.5.20__quasar@2.18.6_sass@1.97.3_tslib@2.8.1_ea0679f3401f6e63bbfdc4dae8ab5531/node_modules/@quasar/app-webpack/types/bex/entrypoints/content.d.ts"
|
"./../node_modules/@quasar/app-webpack/types/bex/entrypoints/content.d.ts"
|
||||||
],
|
],
|
||||||
"#q-app/bex/private/bex-bridge": [
|
"#q-app/bex/private/bex-bridge": [
|
||||||
"./../node_modules/.pnpm/@quasar+app-webpack@4.3.2_pinia@3.0.4_vue@3.5.20__quasar@2.18.6_sass@1.97.3_tslib@2.8.1_ea0679f3401f6e63bbfdc4dae8ab5531/node_modules/@quasar/app-webpack/types/bex/bex-bridge.d.ts"
|
"./../node_modules/@quasar/app-webpack/types/bex/bex-bridge.d.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user