Closed ondrap closed 8 years ago
Currently hookAny is a catch-all handler, catching everything when nothing else matches. What you'd like to do is currently not possible. We would probably have to modify the routing algorithm implemented in reroute
a bit. Would you be interested in giving this a shot?
Ok, I'll try to see this as soon as I finish some projects I'm doing right now... I'll see if I am able to grasp the type labyrinth that makes the whole thing work...
Okay, thanks :-) In 2 weeks I will have more time myself and could take a look. If you're stuck or have questions let me know.
This is essentially nested routing, right? I've been looking around at nested routing solutions in Haskell recently, and there don't seem to be a ton of them!
Depends on what you mean by nested routing. Nested routing w/o capturing parameters is possible with Spock (subcomponent
).
Spock's existing routing seems great - I love the use of HVect
to build handlers with typesafe arguments for route parameters. Essentially I'm looking for a nested version of that. I'm going to have a swing at writing something myself and see how it goes.
The next frontier is making it reversible, but that seems wayyy too hard for now :p
We've already started working on that some time ago, but did not have the time to finish it yet. See the branch in reroute: https://github.com/agrafix/reroute/tree/subcomponents . If you like you can take that as a base and continue working on it - I'll be happy to guide you!
I've updated the issue to make it more clear
Since I'm here now (thanks, GitHub notifications!) I shall mention I'm still toying with ideas around this. I've started a library based on the same central idea as reroute (heterogeneous lists) but with other goals. Hopefully I'll have something demonstrable soon.
(I've been doing a lot of work in Laravel recently and the experience is leading me towards designing my own Haskell micro-framework. It's a bit of a non sequitur to say PHP has influenced my ideas for a Haskell framework, but we'll see...)
We might be working on this at ZuriHac but if you already have a design then maybe you could share so we could iterate on that? :-)
Ooh, that''s great to hear. If only I lived somewhere that had events like that :relieved:. I'll send you an email!
It should be possible to match against a request that starts with a prefix, for example:
should match all routes that start with
/app/...
.Questions:
Original:
I would need to catch a whole subtree to run an action. To catch the whole "/app/...", I tried this:
However, that doesn't seem to work as expected - instead of 404, I get the
servePage
result when any non-handled page is requested - even outside of "/app". Is this an error or is it expected to behave this way? What is the proper way to do this?