[web-devel] Need a subsite example/tutorial/documentation
michael at snoyman.com
Thu Mar 17 19:33:49 CET 2011
On Thu, Mar 17, 2011 at 8:01 PM, <vagif.verdi at gmail.com> wrote:
> Both Snap and Happstack can match against partial route. And after handling it
> let it fall deeper to the next handler.
> Does yesod routing support such model ?
Sure, just use MultiPieces. For example:
mkYesod "MyApp" [$parseRoutes|
/*Strings RootR GET
getRootR  = ...
getRootR ["hello"] = ...
getRootR ("something":rest) = go rest
But even though you *can* do it, that doesn't mean I recommend it. One
of the major features that Yesod gives you versus Snap or Happstack is
type-safe URLs. Doing these kinds of matches undercuts that feature
drastically. So sure: contrary to popular belief, Yesod can express
the full routing flexibility present in Happstack and Snap. But
there's a very good reason to use the recommended approaches whenever
I think that isAuthorized should provide you with the tool you need
to achieve this. I've written sites with very complex permissions code
using isAuthorized, and frankly I think it's a much better and simpler
approach to many other authorization systems out there. (And yes, I
would love to augment the Yesod book with some documentation on it.)
>> You should be able to avoid a subsite by checking the url in the
> auhorization callbacks.
> Could you please elaborate. I do not even know where to begin to look for such
> The scaffolded site has an authentication example. But it is implemented as a
> subsite. And i have a hard time figuring out how to create a subsite without a
I don't think a subsite is the solution you are looking for here. It
*could* solve your problem, but it would not be the most pleasant
approach. Subsites should be saved for reusable components whenever
More information about the web-devel