Skip to content

Named route group #253

Description

@decebals

The idea is that we add a new named method on RouteGroup similar with the same method from Route.

Show me the code:

// create the group with a nameRouteGroupgroup = newRouteGroup("/users").named("users.");
// add routes for groupgroup.GET("/", ...).named("getAll");
group.GET("/{id}", ...).named("get");
group.PUT("/{id}", ...).named("update");
group.DELETE("/{id}", ...).named("delete");
// add route group to applicationaddRouteGroup(group);

The idea is that the route name is prefixed automatically with the group name.
Now, you may use the route's name when generating URLs or redirects:

Map<String, Object> parameters = ...
routeContext.uriFor("users.getAll", parameters);
routeContext.uriFor("users.get", parameters);
routeContext.uriFor("users.update", parameters);
routeContext.uriFor("users.delete", parameters);
// the same for redirectrouteContext.redirect("users.getAll", parameters);
...

In my example I used . as separator but you can use any character or string.

What you think?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions