Iris: HandleDir redirects the files [BUG]

Created on 13 Nov 2020  Â·  2Comments  Â·  Source: kataras/iris

Describe the bug
When I use "HandleDir" function to set a folder static, the function properly shows and list files and folders (showlist true). but when I click to file like this: "http://localhost:8000/public/assets/css/style.css", it redirects to "http://localhost:8000/public/assets/css/".
Turning on or off "Show list " doesn't affect the problem.

package main

import "github.com/kataras/iris/v12"

func main() {
    app := iris.New()

    index := func(ctx iris.Context) {
        ctx.StatusCode(200)
        ctx.JSON(iris.Map{"message": "This is a message"})
    }
    app.Get("/", index)
    app.HandleDir("/public", iris.Dir("./public/"), iris.DirOptions{ShowList: true})
    app.Listen(":8000")
}

Screenshots
Folder Structure :
image

Desktop (please complete the following information):

  • OS: Windows 10

iris.Version
github.com/kataras/iris/v12@master (v12.2.0)

high resolved bug

All 2 comments

Hello @sajadko, you are right, I am able to re-produce that one. Expect a fix soon.

OK. It's fixed now, update to the latest master. It was a simple check of options.IndexName != "". The IndexName field is optional now, and in your example it was empty, however, I suggest always set-ing it on index.html unless it's not required at all.

Was this page helpful?
0 / 5 - 0 ratings