Function Signatures
cajund opened this issue · comments
Hi Folks,
I'm attempting to wrap your library in an additional abstraction library of my own design. The intention is to create convenience functions to create REST services. This may be more of a Go question than anything, but I have tracked the problem down to your validation code when adding handlers (isValidHandler
).
Your functions require the following signature:
func YourFunctionName(rw web.ResponseWriter, req *web.Request)
So that all of my libraries that create handlers aren't required to include your library as well as my new one, I have created a set of types to accommodate your signatures:
type PathHandler func(rw WebWriter, req *WebRequest)
type WebWriter web.ResponseWriter
type WebRequest web.Request
In this manner, my functions can adhere to this type PathHandler
func Read(rw WebWriter, req *WebRequest) {
...
}
func GenerateReadEndpoint() PathHandler {
return Read
}
The code panics when trying to add the handler via router.Get()
etc., as the isValidHandler
function rejects the types I have created.
Is there any way to accomplish this, or do you have a function type that I may have missed that I can use to abstract your library?
Thanks.