-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Fixes: #4597 Parse URI path with an endpoint #9728
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
Conversation
@JamesNK looking for your COOL high level feedback on this before adding tests. |
This is also pretty simple and straightforward compared to what we have today 👍 |
There's a few more decisions here to be made like - does this apply default values? Does this run constraints? I'm planning to reach out to some of the folks that asked for this feature and poll them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems alright.
It does feel a little odd to have matching on link generator. Consider whether a new type makes sense. LinkParser
?
public override RouteValueDictionary ParsePathByAddress<TAddress>(TAddress address, PathString path) | ||
{ | ||
var endpoints = GetEndpoints(address); | ||
if (endpoints.Count == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How/where is GetEndpoints implemented? This was my issue, getting access to the routes/endpoints that used to be in RouteData.Routes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get endpoints is implemented on the base class.
If you want a list of all of the endpoints in the app, you do do that by grabbing EndpointDataSource
from DI. If you want the endpoint that matched the current request, use this. https://github.com/aspnet/AspNetCore/blob/425c196cba530b161b120a57af8f1dd513b96f67/src/Http/Http.Abstractions/src/Routing/EndpointHttpContextExtensions.cs
3c2c6a2
to
39622b1
Compare
@JamesNK - ready for review. I decided to go with a separate class. |
src/Http/Routing/src/LinkParserEndpointNameAddressExtensions.cs
Outdated
Show resolved
Hide resolved
39622b1
to
61306cf
Compare
@JamesNK updated |
Adds functionality to LinkGenerator to parse a URI path given a way to find an endpoint. This is the replacement for various machinications using the global route collection and `RouteData.Routers` in earlier versions. For now I'm just adding a way to do this using Endpoint Name since it's a pretty low level feature. Endpoint Name is also very direct, so it feels good for something like this. I added this to LinkGenerator because I think it feels like the right thing do, despite the naming conflict. I don't really want to create a new top-level service for this.
61306cf
to
b55ec1c
Compare
@JamesNK updated |
Adds functionality to LinkParser to parse a URI path given a way to
find an endpoint. This is the replacement for various machinications
using the global route collection and
RouteData.Routers
in earlierversions.
For now I'm just adding a way to do this using Endpoint Name since it's
a pretty low level feature. Endpoint Name is also very direct, so it
feels good for something like this.
Example usage: