Skip to content

Instantly share code, notes, and snippets.

@LeviSchuck
Created June 8, 2013 04:43
Show Gist options
  • Save LeviSchuck/5734068 to your computer and use it in GitHub Desktop.
Save LeviSchuck/5734068 to your computer and use it in GitHub Desktop.
-- No hiding Route
import Yesod as Import
-- ...
--Assumes that "App" is your context
type RouteRenderer = (Route App -> Text)
getAPIR :: Handler TypedContent
getAPIR = do
render <- getUrlRender
selectRep $ do
provideRep $ returnJson $ getAPIJson render
getAPIJson :: RouteRenderer -> Value
getAPIJson render = object $ ([
"auth_url" .= render HomeR,
"potato" .= ("Apples"::Text),
"eggs" .= object ([
"happy" .= (32.4::Double)
]),
"chocolate" .= object ([
"hello" .= True,
"nest" .= object ([
"things" .= render APIUsersR
])
])
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment