Skip to content

Provide shortcut methods for routing [SPR-14953] #19520

Closed
@spring-projects-issues

Description

@spring-projects-issues

Sébastien Deleuze opened SPR-14953 and commented

Currently, we declare routes like that:

route(GET("/foo/**"), r -> ok().body(fromObject("foo")))
		.andRoute(GET("/bar/**"), r -> ok().body(fromObject("bar")))
		.andRoute(POST("/baz/**"), r -> ok().body(fromObject("baz")))

This is a very common use case that deserves IMO syntactic sugar to make routes more readable and maintainable. Something like:

routeGet("/foo/**", r -> ok().body(fromObject("foo"))
		.andRouteGet("/bar/**", r -> ok().body(fromObject("bar"))
		.andRoutePost("/baz/**", r -> ok().body(fromObject("baz"))

That will still allow to use the current more powerful/evolutive API while providing some nice shortcuts for this kind of code that application developers will have to write so many times.


Issue Links:

1 votes, 3 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions