gocraft/web

static_middleware hardcoded to accept string instead of http.Dir

DanielHeath opened this issue · 3 comments

The HTTP package in go has a Filesystem interface so that you don't have to back your server with a real fileserver.

In static_middleware.go, the string param type means that you can't use anything other than a real OS file; a call-path that accepted any http.Filesystem would let me use (e.g.) github.com/jteeuwen/go-bindata

@DanielHeath it's pretty easy to change it, but that would break back-compat unless there's another helper method: StaticMiddlewareFromDir(d http.Dir)

I think I prefer to keep this issue open, and see if any other breaking changes need to be done, and then bundle the breaking changes together. In the mean time, it's obviously pretty easy for you to copy/paste the middleware into your app.

I'd avoid breaking changes for this - StaticMiddlewareFromDir would be fine, and would add almost no extra code.

Merged PR. Closing this.