-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
WHATWG URL Pattern: support for route matching #679
Comments
Can you be more precise as to what you mean by 'route matching'. Do you refer to a specification? |
@lemire ,I actually mean the user's route tokens, which is the main task of a router. as an example the following list may help
Of course, there may be specifications you want to stick to. But in general, I think it is very important to provide this structure that every http router basically needs. NodeJS uses your library if I'm not mistaken. Most routers under nodejs (expressjs, fastify ...) really waste time in the matching part. This feature can significantly improve the performance of such libraries |
@meftunca My question stands: what is the specification you are are referencing? To be clearer, you propose that routing be implemented in ada, but a pre-requisite is that one has a formal definition of what routing means. The one thing that comes to mind is the WHATWG URL Pattern specification. Is that what you mean, or do you mean something else? |
Hello, The feature I propose is to add URL routing, a common mechanism in web applications, to the ada-url library. This feature would allow incoming HTTP requests to be routed to the appropriate handler functions by matching their URLs against specific patterns. This feature would expand the scope of ada-url, making it easier to develop more comprehensive web applications. For example, this feature would be very useful when building a REST API or serving different content to different URLs. My proposed solution is to use placeholder values like /users/:id/friends in URL patterns. These placeholders would be matched with the actual values in the request's URL and passed as parameters to the handler function. Additionally, more flexible matching rules could be defined with dynamic segments like {id} or regex expressions like [a-zA-Z]. As ada-url already has the ability to parse URL parts, adding this feature could be relatively easy. This would allow application developers to perform URL routing using only the ada-url library. This feature would make ada-url a more powerful and versatile tool, making life easier for many developers like me. |
Ok. So we agree that the issue about WHATWG URL Pattern. I have retitled it. |
Hi folks, I started work on adding URL Pattern to Ada. I'm new-ish to C++ and this is my first contribution to this repo, so it's taking me a little longer to figure out but chipping away slowly at it! I'll open a draft PR when its in a better state, but for now you can see the working branch: main...Ethan-Arrowood:ada:add-url_pattern |
What is the problem this feature will solve?
With this support we can increase the spread of ada-url. The library is really fast, but by adding a route matching feature for url, it can be a really inclusive library.
What is the feature you are proposing to solve the problem?
Here is my proposed solution:
/users/:id/friends with “:/” separated by the character “:/” to enable route matching. Of course, there may be more specific examples like
“{id}”,“[a-zAz]”
What alternatives have you considered?
Since this suggestion is usually found in router libraries, it is difficult to give a specific reference, but I have listed an example of its use below
The text was updated successfully, but these errors were encountered: