Skip to content
New issue

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

Function Signatures #82

Open
cajund opened this issue Feb 28, 2018 · 0 comments
Open

Function Signatures #82

cajund opened this issue Feb 28, 2018 · 0 comments

Comments

@cajund
Copy link

cajund commented Feb 28, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant