Skip to content

Commit

Permalink
fix: absolute Paths conf.WebDir
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuchange committed Dec 16, 2020
1 parent 0f3523b commit d324c49
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
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
4 changes: 2 additions & 2 deletions api/internal/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,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(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", 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
echo "failed: manager-api cant run on a different path"
exit 1
fi

cd -
rm -rf html
clean_up

# test start info

Expand Down

0 comments on commit d324c49

Please sign in to comment.