buffalo: Reproducible problem with app.Mount (just Copy & Paste).
If you copy & paste the code below you can reproduce the problem with app.Mount:
actions/app.go:
package actions
import (
"fmt"
"github.com/gobuffalo/buffalo"
"github.com/gobuffalo/envy"
"github.com/gorilla/mux"
"net/http"
)
var ENV = envy.Get("GO_ENV", "development")
var app *buffalo.App
func funcTest(res http.ResponseWriter, req *http.Request) {
fmt.Fprintf(res, "%s - HELLOOOOOOOOOOOOO - %s", req.Method, req.URL.String())
}
func muxer() http.Handler {
r := mux.NewRouter()
r.HandleFunc("/foo", funcTest).Methods("GET")
r.HandleFunc("/bar", funcTest).Methods("POST")
r.HandleFunc("/baz/baz", funcTest).Methods("DELETE")
return r
}
func App() *buffalo.App {
if app == nil {
app = buffalo.New(buffalo.Options{
Env: ENV,
SessionName: "_mytestapp_session",
})
app.Mount("/admin", muxer())
app.Mount("/strip", http.StripPrefix("/strip", muxer()))
app.ANY("/test/{path:.+}", buffalo.WrapHandler(http.StripPrefix("/test", muxer())))
app.GET("/one", buffalo.WrapHandlerFunc(funcTest))
app.GET("/", HomeHandler)
app.ServeFiles("/", assetsBox)
}
return app
}
-
If you visit http://localhost:3000/admin/foo or http://localhost:3000/test/foo or http://localhost:3000/strip/foo is the same:
404 page not found. -
If you visit: http://localhost:3000/one it works.
I think there is a problem with app.Mount in Buffalo.
Fixing this we can close this and other 2 related issues I think:
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (17 by maintainers)
I’m sorry, I can’t write this code for you. I’m supporting this in my free time. It’s sunday morning.
app.Mount(somehandlerthatstripsthelastslash(youmux)) On Dec 16, 2018, 8:57 AM -0500, frederikhors notifications@github.com, wrote: