StaticMiddleware() is not working
yvasiyarov opened this issue · comments
Yuriy Vasiyarov commented
Hello,
I've created simple application:
package main
import (
"github.com/gocraft/web"
"net/http"
)
type Context struct{
}
func main() {
router := web.New(Context{}).
Middleware(web.LoggerMiddleware).
Middleware(web.ShowErrorsMiddleware).
Middleware(web.StaticMiddleware("public"))
http.ListenAndServe("localhost:8080", router)
}
in the same folder I have "public" directory with "index.html" file inside.
If I make "http://localhost:8080/index.html" request, I got "404 page not found"
any idea why ?
Andri Óskarsson commented
Have you tried "./public" and made sure that your "public" directory is in the same directory as your main file? I ask because I made the mistake of having my main.go in a "bin/" directory and couldn't understand why static wasn't working. Obviously, I needed to ask for "../public" in that case.
Jonathan Novak commented
@yvasiyarov lmk if andrioid's advice didn't help. This wfm.