Skip to content

Commit 9758d91

Browse files
committed
Доработка отдачи статики
1 parent b6e5d3e commit 9758d91

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

api/base.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"polkovnik/domain"
1010
"polkovnik/job"
1111
"polkovnik/repository"
12+
"strings"
1213
"time"
1314
)
1415

@@ -107,7 +108,14 @@ type SpaHandler struct {
107108
}
108109

109110
func (h SpaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
110-
_, err := h.Files.Open(h.StaticPath + r.URL.Path)
111+
path := h.StaticPath + r.URL.Path
112+
113+
//Если запрашивается папка, то нужно смотреть на индексный файл
114+
if strings.HasSuffix(path, "/") {
115+
path = path + h.IndexPath
116+
}
117+
118+
_, err := h.Files.Open(path)
111119

112120
//Если запрашиваемого файла нет, отдаем главную страницу. Далее отработает роутинг в JavaScript
113121
if os.IsNotExist(err) {

0 commit comments

Comments
 (0)