question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

High level api for route parameters.

See original GitHub issue

Add support for multiple route parameters deserialisation.

It can be similar to HasUrlParameter which supports deserialisation of one route parameter.

Make use of the route parameters api implemented in https://github.com/vaadin/flow/pull/7608.

Related to https://github.com/vaadin/flow/issues/2740 and https://github.com/vaadin/flow/issues/4213

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Legiothcommented, Apr 15, 2020

My hypothesis is that at least 80% of all cases will need only one parameter. Out of the remaining 20%, another 80% will need only two parameters and so on.

The 80% case with only one parameter is already nicely served by the current HasUrlParameter<T> API. My main question is whether any design for he remaining 20% would bring so much improvements to application cod that it would be worth the investment from our side compared to some other DX improvements that we could do that would target some more common use case.

Other cases can with relatively little boilerplate do something like this:

String param1 = parameters.get("foo").orElse(null);
int param2 = parameters.get("bar", -1);

Introducing a DTO for those two parameters would require the additional overhead of actually defining that DTO class. That DTO could then be used in combination with the current one-parameter approach as HasUrlParameter<DtoType>. The actual routing code could then be simplified to this:

String param1 = dto.getFoo();
int param2 = dto.getBar();

The reduction in the needed code is quite minimal, but a secondary benefit is that type conversions and magic strings are moved out of sight. Another benefit is the possibility of creating a RouterLink based on an instance of dto (which would work without additional API additions if done based on HasUrlParameter<DtoType>).

0reactions
bogdanudrescucommented, Apr 17, 2020

Actually, in our routing context there should be no need for handling these exceptions if the route is defined correctly. If the regex assigned to the route parameter doesn’t match the value of the parameter in the url, then the navigation fails before reaching conversion phase.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Step 3: Parameters (API reference tutorial) | Documenting APIs
In this example, the parameters are grouped by type: path parameters, query parameters, and body parameters. The endpoint also sets off the path ......
Read more >
Routes API migration guide - Google Developers
This guide describes how to migrate your existing apps that use the Directions API and Distance Matrix API to use the new Routes...
Read more >
Common Routing Parameters | Routing API and Extended ...
The Common Routing Parameters section describes common parameters that affect the routing algorithm in various ways. The Consumption Model ...
Read more >
Attribute Routing in ASP.NET Web API 2 | Microsoft Learn
Web API 2 supports a new type of routing, called attribute routing. As the name implies, attribute routing uses attributes to define routes....
Read more >
8.4: RESTful Routes with Parameters - Programming with Text
In "Building an API in Node" video for the ITP course "Programming from A to Z", I expand on the previous video ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found