[web-devel] web-devel Digest, Vol 71, Issue 1

Greg Weber greg at gregweber.info
Mon Oct 26 14:04:38 UTC 2015


On Mon, Oct 26, 2015 at 6:30 AM, Julian Arni <jkarni at gmail.com> wrote:

> (Sorry for the delay, was away for the weekend.)
>
>
>
> On Sat, Oct 24, 2015 at 2:05 AM, Greg Weber <greg at gregweber.info> wrote:
>
>> Yes, that is all very clear. My contention is that one should not have
>> overlapping routes, particularly when mounting an Application.
>> If an Application is mounted at /route, then it should be clear that
>> /route* should belong to the Application.
>>
>> For example, with Yesod, Yesod "stands in front", but one often mounts
>> wai-app-static at /static and Yesod will statically enforce that you don't
>> create another static/* route anywhere else.
>>
>> What is the use case for having one framework "stand in front" such that
>> it requires overlapping, or what is the use case for overlapping otherwise?
>>
>> Well, my thought was that Application is, modulo this one problem,
> already a way of sharing handlers (or sets of handlers) between frameworks.
> If overlaps are handled nicely, one can combine different web frameworks
> very neatly. This seems to achieve the original aim, but maybe I'm missing
> some of the motivation for a common handler?
>

This is the aim, the question is just whether overlapping routes are useful.


>
> As for a use case for standing-in-front, it's sort of a nice way to have
> something like a reverse proxy that captures some endpoints rather than
> proxying them to the underlying service, without the actual overhead of
> external requests. I imagine there are other use-cases.
>

It seems like a 404 response would be sufficient for something behaving
like a proxy.


> Finally, it seems like if we had a good story about Applications working
> anywhere - in particular, converting one or more endpoints to Application
> and then mounting them in the same place not changing the behaviour of the
> overall Application - it would be quite easy for all web frameworks to
> apply Middleware to a subset of endpoints rather than all of them.
>

It should be easy enough to apply a middleware to selected applications. If
they are already combined with routing one can still use a Routed
Middleware:
https://github.com/yesodweb/wai/blob/master/wai-extra/Network/Wai/Middleware/Routed.hs

So I am still looking for a very concrete (code) example where overlapping
routing is desirable. I can point you to the yesod-scaffold where we
explicitly avoid overlapping routes and have applications at /auth and
/static
https://github.com/yesodweb/yesod-scaffold/blob/postgres/config/routes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/web-devel/attachments/20151026/2a61fdaa/attachment.html>


More information about the web-devel mailing list