justinas/alice

inconvenient Constructor type alias

arussellsaw opened this issue · 2 comments

type Constructor func(http.Handler) http.Handler is used for defining middleware functions, and is used as part of New(constructors ...Constructor) { this has caused some problems for me due to the lack of implicit type aliasing on sliced variadic parameters. example here: https://play.golang.org/p/5arBiRLckG
the issue i'm facing is that i'm writing a package where i'd like to users to be able to define a slice of func(http.Handler) http.Handler and not have to import alice in order to provide them. i know i can iterate and manually do the type conversion, and i'm doing that for now, but i figured i'd make this issue anyway just as something for you to consider.

Thanks

Maybe add a little wrapper function like so: https://play.golang.org/p/OTP4olTA6T?

The life of users of this package would be easier by just defining Constructor as a type alias instead of a "hard" type:

type Constructor = func(http.Handler) http.Handler

That would solve @arussellsaw's problem.