Skip to content

Commit bc49230

Browse files
committed
Replace all forward slashes
1 parent 335ff99 commit bc49230

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
version=fake
22
ifeq ($(OS),Windows_NT)
33
bin=main.exe
4+
build_bin=tmp\main.exe
45
else
56
bin=main
7+
build_bin=tmp/main
68
endif
79
# Example:
810
# make
@@ -53,6 +55,6 @@ build-frontend:
5355

5456
.PHONY: serve-backend
5557
serve-backend:
56-
air --build.cmd "go build -o ./tmp/$(bin) ." --build.bin "tmp/$(bin)" --build.exclude_dir "assets,docs,tmp,web,scripts,ssh-key,.github,.git" --build.include_ext "go,yaml,html,js" --build.exclude_file "config.example.yaml" --build.args_bin "dashboard,--config,config-test.yaml" --build.stop_on_error true --misc.clean_on_exit true --log.time true
58+
air --build.cmd "go build -o ./tmp/$(bin) ." --build.bin "$(build_bin)" --build.exclude_dir "assets,docs,tmp,web,scripts,ssh-key,.github,.git" --build.include_ext "go,yaml,html,js" --build.exclude_file "config.example.yaml" --build.args_bin "dashboard,--config,config-test.yaml" --build.stop_on_error true --misc.clean_on_exit true --log.time true
5759

5860
app: build-frontend serve-backend

cmd/api.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import (
2222
"net/http"
2323
"os"
2424
"path"
25+
"runtime"
2526
"strconv"
27+
"strings"
2628

2729
"github.com/bisohns/saido/client"
2830
"github.com/bisohns/saido/config"
@@ -50,13 +52,18 @@ func (f fsFunc) Open(name string) (fs.File, error) {
5052

5153
func EmbedHandler(prefix, root string) http.Handler {
5254
handler := fsFunc(func(name string) (fs.File, error) {
55+
defaultPath := fmt.Sprintf("%s/index.html", root)
5356
assetPath := path.Join(root, name)
57+
if runtime.GOOS == "windows" {
58+
defaultPath = strings.ReplaceAll(defaultPath, `/`, `\`)
59+
assetPath = strings.ReplaceAll(assetPath, `/`, `\`)
60+
}
5461

5562
// If we can't find the asset, return the default index.html
5663
// build
5764
f, err := build.Open(assetPath)
5865
if os.IsNotExist(err) {
59-
return build.Open(fmt.Sprintf("%s/index.html", root))
66+
return build.Open(defaultPath)
6067
}
6168

6269
// Otherwise assume this is a legitimate request routed

0 commit comments

Comments
 (0)