Skip to content

Commit a36d23e

Browse files
authored
Merge pull request #626 from ansible-semaphore/fix-static-content-routing
Fix static content routing
2 parents 620e873 + 060f4d9 commit a36d23e

File tree

5 files changed

+17
-37
lines changed

5 files changed

+17
-37
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ aliases:
99
# git clone -b $CIRCLE_BRANCH https://github.com/ansible-semaphore/semaphore.git ./
1010

1111
- &golang-image
12-
image: circleci/golang:1.15.5
12+
image: circleci/golang:1.13
1313

1414
- &working-dir
1515
/go/src/github.com/ansible-semaphore/semaphore

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ web/public/js/bundle.js
44
web/public/css/*.*
55
web/public/html/**/*.*
66
web/public/fonts/*.*
7-
web2/dist
87
web2/.nyc_output
8+
web2/dist/**/*
99
config.json
1010
.DS_Store
1111
node_modules/

Taskfile.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ tasks:
127127
- db/db-packr.go
128128
- api/api-packr.go
129129
cmds:
130+
- mkdir -p web2/dist
130131
- go run util/version_gen/generator.go {{ if .TAG }}{{ .TAG }}{{ else }}{{ if .SEMAPHORE_VERSION }}{{ .SEMAPHORE_VERSION }}{{ else }}{{ .BRANCH }}-{{ .SHA }}-{{ .TIMESTAMP }}{{ if .DIRTY }}-dirty{{ end }}{{ end }}{{end}}
131132
- packr
132133
vars:

api/router.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,8 @@ import (
1616
"github.com/russross/blackfriday"
1717
)
1818

19-
var publicAssets packr.Box
20-
21-
func getPublicAssetsPath() string {
22-
if util.Config != nil && util.Config.OldFrontend {
23-
return "../web/public"
24-
}
25-
26-
return "../web2/dist"
27-
}
19+
var publicAssets = packr.NewBox("../web/public")
20+
var publicAssets2 = packr.NewBox("../web2/dist")
2821

2922
//JSONMiddleware ensures that all the routes respond with Json, this is added by default to all routes
3023
func JSONMiddleware(next http.Handler) http.Handler {
@@ -58,8 +51,6 @@ func notFoundHandler(w http.ResponseWriter, r *http.Request) {
5851

5952
// Route declares all routes
6053
func Route() *mux.Router {
61-
publicAssets = packr.NewBox(getPublicAssetsPath())
62-
6354
r := mux.NewRouter().StrictSlash(true)
6455
r.NotFoundHandler = http.HandlerFunc(servePublic)
6556

@@ -271,7 +262,18 @@ func servePublic(w http.ResponseWriter, r *http.Request) {
271262
split := strings.Split(path, ".")
272263
suffix := split[len(split)-1]
273264

274-
res, err := publicAssets.MustBytes(path)
265+
fmt.Println("path")
266+
fmt.Println(path)
267+
268+
var res []byte
269+
var err error
270+
271+
if util.Config.OldFrontend {
272+
res, err = publicAssets.MustBytes(path)
273+
} else {
274+
res, err = publicAssets2.MustBytes(path)
275+
}
276+
275277
if err != nil {
276278
notFoundHandler(w, r)
277279
return

web2/.gitignore

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)