iris icon indicating copy to clipboard operation
iris copied to clipboard

router 404 when using app.StaticEmbedded

Open xkylsoft opened this issue 9 years ago • 4 comments

my code

    app.StaticEmbedded("/", "static", Asset, AssetNames)

when routing localhost:8080 404 not found bug code iris/core/router/fs.go line 71

    if path == "/index.html" && reqPath == "/" {
	reqPath = "/index.html"
    }

path is allways hax prefix "static" and path == "/index.html" is false all the time resolve by change code to

    if reqPath == "" || reqPath == "/" {
        reqPath = "/index.html"
    }

xkylsoft avatar Sep 22 '17 02:09 xkylsoft

another problem at iris/core/router/fs.go line 75 , + make the seperate error

    if dpath != vdir + reqPath {
        continue
    }

resolve by change code to

   if dpath != path.Join(vdir, reqPath) {
        continue
   }

xkylsoft avatar Sep 22 '17 02:09 xkylsoft

You don't use the StaticEmbedded correct, this is why you get these errors, please read the examples at least before post an issue or give us a full code snippet in order to work on.

hiveminded avatar Sep 22 '17 10:09 hiveminded

my code is as same as the examples , only change is folder name , but not running correct this is the full code

func main() {
	app := iris.New()
	app.Use(recover.New())
	app.Use(logger.New())

	app.StaticEmbedded("/", "./static", Asset, AssetNames) 
	app.Run(iris.Addr(":8054")) 
}

go-bindata command

go-bindata -o bindata.go ./static/...

static file

static\
        index.html
        lib\
             index.js

xkylsoft avatar Sep 27 '17 03:09 xkylsoft

@xkylsoft Thank you for the report, sorry for the delay I have some other priorities this week, I just fixed it, just upgrade with go get -u github.com/kataras/iris and you should be fine, tell me the results :)

kataras avatar Oct 01 '17 03:10 kataras