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

Make server Endpoints methods return arrays instead of maps #173

Open
jprobinson opened this issue Jan 3, 2019 · 3 comments
Open

Make server Endpoints methods return arrays instead of maps #173

jprobinson opened this issue Jan 3, 2019 · 3 comments
Assignees

Comments

@jprobinson
Copy link
Contributor

Maps do not allow users to declare the order in which their endpoints are registered against our routers, which can force developers to compromise how their URIs are constructed or even force users to build custom router implementations.

By switching to an array, users will be allowed to declare the order in which routes will be registered. Long term goal here is to eventually open up a path for us to remove any custom routing options in the future and purely rely on gorilla/mux.

I haven't figured out exactly what this API will look like, but I hope the change to be simple enough that minimal refactoring is required for the upgrade.

@jprobinson jprobinson self-assigned this Jan 3, 2019
@marwan-at-work
Copy link
Contributor

Why not just let the user provide the ServerMux?

@jprobinson
Copy link
Contributor Author

The kit server allows folks to provide their own custom mux, but I think that may be tossing the problem over the fence at the user. They'd still have to selectively iterate over the map in the order they choose.

I do like that the current implementation encourages users to provide all the routes encapsulated in a single data structure, which is why I was considering an array/slice here, but perhaps a different paradigm may serve us better?

Any thoughts on what the API would look like?

@marwan-at-work
Copy link
Contributor

@jprobinson I opened a separate issue for passing the Mux directly (#195) which we can discuss how to do that over there.

However, if we want to still have "our own way" of declaring the Routes -> Handlers data structure, then the only reason I see a benefit for this, is that we should do it in a way that we can generate an OpenAPI V3 Spec..this would be a huge win IMO: a user just declares routes in pure Go, and not only do they get working handlers, they get automatic spec and UI documentation.

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