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

Create DSL for RouterFunction and RouterFunctions [SPR-16953] #21491

Closed
spring-projects-issues opened this issue Jun 18, 2018 · 4 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 18, 2018

Arjen Poutsma opened SPR-16953 and commented

We should add a (Java) DSL to org.springframework.web.servlet.function that makes it easier to discover the routing possibilities that all the request predicates offer.

So, instead of writing

RouterFunction routerFunction = route(GET("/pets/{id}", request -> ServerResponse.ok.build())

where both route and GET are statically imported, it should be more discoverable.

For instance, by introducing a builder with methods that directly express common request predicates, eg. routeGET(String, HandlerFunction) instead of route(RequestPredicate, HandlerFunction.


Issue Links:

Referenced from: commits 91e96d8, 8202052

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jun 18, 2018

Adam Berlin commented

I think an improvement might be an instance of a class that includes GET, POST, etc, so that you end up with

route.get("/pets/{id}", request -> ServerResponse.ok.build())

This way, I can discover my options by looking at the route object. When the methods are static methods, it is too easy to pluck them off of their class, and therefore harder to remember where they come from and discover more alternatives.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Reopened after feedback received during Spring meeting.

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Significantly changed the usage of the route builder, based on feedback received during team meeting. See 91e96d8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants