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

Simplified API in the future? Goweb use too many []interface{} for args #71

Open
nvcnvn opened this issue Nov 23, 2013 · 4 comments
Open

Comments

@nvcnvn
Copy link

nvcnvn commented Nov 23, 2013

I'm going to use Goweb for the next project, after reading the API document I feel Goweb use too many ...interface{} for the function agrs. I give some flexible but sometime give some confusions.
Why don't we just provide the most general API for the function?
For example, goweb.Map should be:

func Map(fn func(c context.Context) error, path string, methods []string, matchers []handlers.MatcherFunc) (handlers.Handler, error)

or goweb.MapController should be just:

func MapController(controller interface{}, path string) error

I know this is not that importan and hard to change because you will break your old code but it still worth something! I bet that many of us love Go because the simplicity and clarity (by the lack of function overloading and something else)

Thanks for the team for your great package!

@matryer
Copy link
Member

matryer commented Nov 23, 2013

Thanks for that feedback. Some good points.

Mat

Sent from my iPhone

On 22 Nov 2013, at 20:20, nvcnvn [email protected] wrote:

I'm going to use Goweb for the next project, after reading the API document I feel Goweb use too many ...interface{} for the function agrs. I give some flexible but sometime give some confusions.
Why don't we just provide the most general API for the function?
For example, goweb.Map should be:

func Map(fn func(c context.Context) error, path string, methods []string, matchers []handlers.MatcherFunc) (handlers.Handler, error)
or goweb.MapController should be just:

func MapController(controller interface{}, path string) error
I know this is not that importan and hard to change because you will break your old code but it still worth something! I bet that many of us love Go because the simplicity and clarity (by the lack of function overloading and something else)

Thanks for the team because you provide a great package!


Reply to this email directly or view it on GitHub.

@matryer
Copy link
Member

matryer commented Nov 25, 2013

You can tell we came from Ruby and JavaScript and not C++ can't you :D

@matryer
Copy link
Member

matryer commented Nov 25, 2013

Do you think adding strict versions would be a pointless thing?

I.e.

goweb.Map(args ...interface{}) (handlers.Handler, error)

AND
goweb.MapS(fn func(c context.Context) error, path string, methods []string, matchers []handlers.MatcherFunc) (handlers.Handler, error)

The Map function would just figure out how to call MapS but hard-corers would be able to just use the MapS function directly?

@nvcnvn
Copy link
Author

nvcnvn commented Nov 26, 2013

I think a strict version should be good for the near future.
But in the far future, remove all the switch case block for determine the type should cleaner and shorten some of your code, do you think so?

P/s:
If there is a strict version, you should use it in your examples/tutorials (person like me will look at them first :D)

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

2 participants