-
-
Notifications
You must be signed in to change notification settings - Fork 599
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
Add RouteContext::method
#1808
Comments
I'm actually not sure what you're asking for. Are you asking for access to the |
Yeah, it was confusing, and I am having a hard time myself trying to put it in words. Let me try again.
Not necessarily the raw HTTP method. It could some sort of "router method" if that makes sense. I understand that Route path and HTTP path are not the same, but most of the time we map them 1:1 for better graceful degradation. In other words, most of the time we want to map:
to:
Regardless of it being rendered by the browser or by the server, Articles will use the value of Articles has no idea about HTTP, it only knows Route, as it should be. Yet, for graceful degradation purposes, most of the time we will have Route path and HTTP path being a 1:1 map. Now lets say we have a POST request:
Today it seems that RouteProps::methods are only used to generate integrations with HTTP frameworks, but Leptos has no concept of Method. I think the absence of this concept makes it harder to create these 1:1 mappings for graceful degradation purposes. A more concrete example can be found here: #1120 This simplistic example is trying to demonstrate how to gracefully degrade when JS is not available, but the implementation is incomplete. It covers the following cases:
These are covered because when But it does not cover the following:
The case above is not covered because when it is rendered on the browser, it will always send a POST request when calling |
As I understand it the answer is that you are looking for the method the current navigation is being rendered in, always interpreting that as GET for a client-side navigation. Which sounds great. And I believe you that it would make that incomplete demo better. It's unlikely I'll have time to work on this any time soon, but if you'd like to make a PR I'd be happy to look at it. |
I'd like to pick this up but I'd like a bit of direction. Would this involve a method on RouteContext that returns the current method? Say a post request on that route should still render that component but the component should be able to query that like in @yokomizor's original comment? |
@zoomiti Yes, that's correct: It is solely a question of adding a method that returns the method by which someone was routed to the current page (using In effect, this would mean
|
@gbj So I have a working implementation of this, should I make an accompanying example? For testing purposes? |
Is your feature request related to a problem? Please describe.
Since
Route
has a method attribute, it would be nice to have a way to use this value inside components.Describe the solution you'd like
App.rs
Page.rs
The text was updated successfully, but these errors were encountered: