Obtaining the Current URL

21 views
Skip to first unread message

Jeffrey Drake

unread,
Oct 10, 2012, 12:54:50 AM10/10/12
to yeso...@googlegroups.com

I have been trying to figure out how to get the current URL for the page.

The closest that I have gotten is:
        renderfunc <- getUrlRender
        aurl <- getCurrentRoute
        let surl = case aurl of
                        Just u -> renderfunc u
                        Nothing -> ""


I get the error:

Foundation.hs:101:46:
    Couldn't match type `sub' with `App'
      `sub' is a rigid type variable bound by
            the type signature for
              defaultLayout :: GWidget sub App () -> GHandler sub App RepHtml
            at Foundation.hs:85:5
    Expected type: Route App
      Actual type: Route sub
    In the first argument of `renderfunc', namely `u'
    In the expression: renderfunc u

I am sure this is very easy to get around, but I cannot think of the way.

Any thoughts on the matter would be appreciated.

Michael Snoyman

unread,
Oct 10, 2012, 1:58:44 AM10/10/12
to yeso...@googlegroups.com
The missing piece here is getRouteToMaster[1], which takes a route
from the subsite and turns it into a route for the master site. So
you'd end up with:

> renderfunc <- getUrlRender
> toMaster <- getRouteToMaster
> aurl <- getCurrentRoute
> let surl = case aurl of
> Just u -> renderfunc $ toMaster u
> Nothing -> ""


[1] http://hackage.haskell.org/packages/archive/yesod-core/1.1.2.1/doc/html/Yesod-Handler.html#v:getRouteToMaster
Reply all
Reply to author
Forward
0 new messages