Building URLs with globbed routing
I'm pretty sure this isn't possible at the moment, or maybe I'm just missing it, but I don't believe there's a way currently to build a URL from an action with globbed routing.
class Reporting::Index < BrowserAction
get "/reporting/*:filter" do
plain_text filter
end
end
# Writing in a spec
client = ApiClient.new
# there's no way to set that filter
response = client.exec(Reporting::Index.with("???"))
There was a whole discussion about this ... what ... 5 years ago? (😱)
Amber has this in amber-router, but it's a surprisingly complicated problem to solve with speed. https://github.com/amberframework/amber-router/blob/master/spec/amber_router/route_set/matching/glob_matching_spec.cr
I may have worded the issue weird. Lucky supports glob routing already. The issue is if you want to construct the route in a spec, there's not a way to do that from the action class. Currently you have to do client.get("/the/path").
Ohhhh my mistake sorry!
I started working on this, but it's sort of an exhausting issue 😫 If anyone is bored and feels like taking it on, you'll need to start here
https://github.com/luckyframework/lucky/blob/e161fc52f88a2047e6aa699089bf1466426c7514/src/lucky/routable.cr#L199
It has to be accounted for in
- url_without_query_params
- path_without_query_params
- route
- with
- both path_from_parts
There's TONS of duplication, but keeping macros DRY is super difficult because context starts to change.