go-martini / martini

Classy web framework for Go

Home Page:martini.codegangsta.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Will an absolute path work for the static directory?

ianwalter opened this issue · comments

Specifying an absolute path of a directory outside of the project doesn't seem to be working for me:

m.Use(martini.Static("/Users/ian/frontend/dist"))

While a directory within the project does.

Hi Ian,

Actually martini.Static accepts not only relative paths but absolute too.
Have you sure that path exists in your system?
A saw the code that treats absolute path. In addtition I did a POC in a Linux system.

// Static returns a middleware handler that serves static files in the given directory.
func Static(directory string, staticOpt ...StaticOptions) Handler {
    if !filepath.IsAbs(directory) {
        directory = filepath.Join(Root, directory)
    }

Thanks Allan, I should have read the code first. I'm new to go but that is pretty straightforward.
It turned out that the mapping of my Docker volume was wrong.