We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This might sound like a dumb question.
With Denco, is it possible to run a function everytime it hit any route?
So if I had something like:
mux := denco.NewMux() handler, err := mux.Build([]denco.Handler{ mux.GET("/", handleRoot), mux.GET("/foo", handleFoo), mux.POST("/bar", handleBar), }) if err != nil { panic(err) } GetSession() log.Fatal(http.ListenAndServeTLS(":443","crt", "key", handler))
How would I run GetSession() every time, no matter what route gets triggered?
Thanks!
The text was updated successfully, but these errors were encountered:
I think the simple workaround is just wrap the handler with a middleware like function
eg.
func Middleware(handler func(), middlewares ...func()) func() { return func() { // TODO: invoke middlewares before handler... } } // usage handler, err := mux.Build([]denco.Handler{ mux.GET("/", Middleware(handleRoot, GetSession)), mux.GET("/foo", Middleware(handleFoo, GetSession)), mux.POST("/bar", Middleware(handleBar, GetSession)), })
Sorry, something went wrong.
No branches or pull requests
This might sound like a dumb question.
With Denco, is it possible to run a function everytime it hit any route?
So if I had something like:
mux := denco.NewMux()
handler, err := mux.Build([]denco.Handler{
mux.GET("/", handleRoot),
mux.GET("/foo", handleFoo),
mux.POST("/bar", handleBar),
})
if err != nil {
panic(err)
}
GetSession()
log.Fatal(http.ListenAndServeTLS(":443","crt", "key", handler))
How would I run GetSession() every time, no matter what route gets triggered?
Thanks!
The text was updated successfully, but these errors were encountered: