Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: absolute Paths conf.WebDir #1055

Merged
merged 3 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
EnvDEV = "dev"
EnvLOCAL = "local"

WebDir = "./html"
WebDir = "html/"
)

var (
Expand Down
6 changes: 4 additions & 2 deletions api/internal/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package internal

import (
"fmt"
"path/filepath"

"github.com/gin-contrib/pprof"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
Expand Down Expand Up @@ -49,9 +51,9 @@ func SetUpRouter() *gin.Engine {
store := cookie.NewStore([]byte("secret"))
r.Use(sessions.Sessions("session", store))
r.Use(filter.CORS(), filter.RequestId(), filter.RequestLogHandler(logger), filter.SchemaCheck(), filter.Authentication(), filter.RecoverHandler())
r.Use(static.Serve("/", static.LocalFile(conf.WebDir, false)))
r.Use(static.Serve("/", static.LocalFile(filepath.Join(conf.WorkDir, conf.WebDir), false)))
r.NoRoute(func(c *gin.Context) {
c.File(fmt.Sprintf("%s/index.html", conf.WebDir))
c.File(fmt.Sprintf("%s/index.html", filepath.Join(conf.WorkDir, conf.WebDir)))
})

factories := []handler.RegisterFactory{
Expand Down
20 changes: 20 additions & 0 deletions api/test/shell/cli_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ if [[ `grep -c "INFO" ./error.log` -eq '0' ]]; then
exit 1
fi

# run on a different path
workDir=$(pwd)
rm -rf html
mkdir html
cd html
echo "hi~" >> index.html
APISIX_API_WORKDIR=$workDir $workDir/manager-api &
sleep 5

res=$(curl http://127.0.0.1:9000)
pkill -f manager-api

if [[ $res == "404 page not found" ]]; then
Fuchange marked this conversation as resolved.
Show resolved Hide resolved
echo "failed: manager-api cant run on a different path"
exit 1
fi

cd -
rm -rf html
clean_up

# test start info

Expand Down