将 http.Handler 放入马提尼酒中
Put the http.Handler in martini
如何像 http.FileServer
一样与马提尼酒集成?
`包主
import (
"github.com/go-martini/martini"
"net/http"
)
func main() {
m := martini.Classic()
//http.Handle("/", http.FileServer(http.Dir("."))) //It doesn't work!
m.Run()
}`
我相信 FileServer 没有直接在 Martini 中使用:参见 issues/20:
Unfortunately The fileserver middleware throws a 404 if there is no match, which means we will need to roll our own
因此PR 26 and commit a945713 in static.go
that you can see in static_test.go
m := New()
r := NewRouter()
m.Use(Static(currentRoot))
m.Action(r.Handle)
如何像 http.FileServer
一样与马提尼酒集成?
`包主
import (
"github.com/go-martini/martini"
"net/http"
)
func main() {
m := martini.Classic()
//http.Handle("/", http.FileServer(http.Dir("."))) //It doesn't work!
m.Run()
}`
我相信 FileServer 没有直接在 Martini 中使用:参见 issues/20:
Unfortunately The fileserver middleware throws a 404 if there is no match, which means we will need to roll our own
因此PR 26 and commit a945713 in static.go
that you can see in static_test.go
m := New()
r := NewRouter()
m.Use(Static(currentRoot))
m.Action(r.Handle)