Skip to content

Commit

Permalink
Add info logging for embedded handler
Browse files Browse the repository at this point in the history
  • Loading branch information
deven96 committed Nov 17, 2022
1 parent bc49230 commit 5724e67
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import (
"net/http"
"os"
"path"
"runtime"
"strconv"
"strings"

"github.com/bisohns/saido/client"
"github.com/bisohns/saido/config"
Expand Down Expand Up @@ -54,14 +52,10 @@ func EmbedHandler(prefix, root string) http.Handler {
handler := fsFunc(func(name string) (fs.File, error) {
defaultPath := fmt.Sprintf("%s/index.html", root)
assetPath := path.Join(root, name)
if runtime.GOOS == "windows" {
defaultPath = strings.ReplaceAll(defaultPath, `/`, `\`)
assetPath = strings.ReplaceAll(assetPath, `/`, `\`)
}

// If we can't find the asset, return the default index.html
// build
f, err := build.Open(assetPath)
log.Info(assetPath, err)
if os.IsNotExist(err) {
return build.Open(defaultPath)
}
Expand Down

0 comments on commit 5724e67

Please sign in to comment.