Hi guys.., I will be very grateful for your support. I have an issue where I cannot get the is_logged_in and id in my context I suspect its because of the # any pointers?
I recently came across something like this and noticed that # in a url is interpreted as a "URL fragment" and anything after it will be omitted from the query params part of the parsed URL.
were you able to make any progress??
ChatGPT found it in the spec:
I just stopped using # in that place. For me it was that I was trying to put a set value in query params, so I had something like ?vals=#{1}&id=123 and changed it to use a vector instead of a set.
makes sense.. suspected this as well..it;s HTTP standards
Or you could URL-encode it as %23
BROWSERS will not send the fragment, and it is a feature
It allow client-only url's
Some history-routing libraries API allow you to use if you want to use fragments or not
https://google.github.io/closure-library/api/goog.history.Html5History.html
HTTP says nothing about fragments. It is a URL thing
You can send fragments to HTTP services using non-browser things, like curl or any other HTTP library (like clj-http)
After a quick round of tests in pedestal, I see that the behavior is kind of undefined:
• using io.pedestal.test/response-for, we get /hello#world in :path-info/:uri
• using jetty, we get only /hello (the fragment is discarded by jetty)
Internally at Nubank, this has been perhaps the top request for Pedestal and strangely, it's never shown up in the issue list until I added it today. https://github.com/pedestal/pedestal/issues/842
I'm trying out pedestal, and I notice as of version 0.7.0-beta-1, the default router cannot disambiguate the following routes, even though they have distinct and unique route names. My reading of pedestal's documentation suggests the unique route names should help the router disambiguate. Excerpt from the routing table printed to the REPL:
:get /item/new :com.example/new-item-page
:get /item/:item-id/view :com.example/view-item-page
In this case, pedestal matches /item/:item-id/view but returns "not found" for /item/new. Whereas,
if I change my "view" route to /item/view/:item-id, then both routes match and work as expected.
Is this known and expected behaviour? If not, then I will tack this observation onto pedestal/issue/842.This is a FAQ about Pedestal's built-in routing. See https://github.com/pedestal/pedestal/issues/842 which is currently Open. If you want to implement conflicting routes (which, in your hopes, will not conflict in practice for one reason or another) you may do so in your own interceptor.
so basically everyone agrees that it is a feature?! laughcry
> Overlapping routes > Basically, I want to do this: >
(GET "/user/*" [] ...)
> (GET "/user/create" [] ...)
> Pedestal allows for map syntax (order-independence), but then forbids cases like this. Reitit makes those a special case that requires exceptional handling.
> But I don’t think there’s anything is wrong with it or that it’s dangerous. It’s a pretty common case, really. Yes, you can’t create a user named "create", but so what?
https://tonsky.me/blog/simple-router/
I agree with this post, I think pedestal just got this wrong.Well, that does open you up to a "degenerate" case: how to you handle a user who'se is is literally create? Do you favor the wild-card over the static, or vice-versa?
At least in 0.7, you'll see all the routes at startup.
Static > wildcard. I think this makes sense, and from what I remember, this is how it works in web projects in other web libraries (maybe not Clojure).
Yea from a quick web search this is what rails does - the wildcard is always the catch-all, last route to be checked.
Since Pedestal has interceptors, it has no need of catch-alls complecting the routers. A router that may process paths in any order could adaptively process the popular paths first.
Reserving some paths, but also using the wildcard, is a bit less principled than the usual "Clojure way". It could be called a hammock failure. It can be done, but it's a kluge and should look and smell like one.
@phill I thought about your advice (thank you!), and figured writing good ol' non-conflicting routes is right and proper here. Among other things, I guess a custom interceptor will hide details from url-for, which would be a downer.