justinas / alice

Painless middleware chaining for Go

Home Page:https://godoc.org/github.com/justinas/alice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why alice doesn't accept a basic handler in the Then() method?

mdfcorp opened this issue · comments

I'm trying to create a website with httprouter and alice. I saw that alice has the nice option to do alice.New().Then() and pass in the Then() a handler to be executed. Sadly, I can only pass a handler declared as this: func myhandler(w http.ResponseWriter, r *http.Request) { if I only wrap it in an http.HandlerFunc() first. Why isn't possible to just pass one of those? Assuming there's a good chance that the majority of the users will be passing one of those handlers there?

Nevermind. I just found the ThenFunc() which allows to pass one like the one I have. It should be good to note that function in the README, too :)