Skip to content

Instantly share code, notes, and snippets.

@jacobstanley
Created June 15, 2010 18:53
Show Gist options
  • Save jacobstanley/439519 to your computer and use it in GitHub Desktop.
Save jacobstanley/439519 to your computer and use it in GitHub Desktop.
site :: MVar SimState -> Snap ()
site sim = catch500 $
ifTop (fileServe "static/index.html")
<|> route [ ("vessel/speed/:speed", method PUT putSpeed sim)
, ("vessel", method GET getSim sim)
]
<|> fileServe "static"
-- putSpeed :: MVar SimState -> Snap ()
-- getSim :: MVar SimState -> Snap ()
site :: MVar SimState -> Snap ()
site sim = catch500 $
ifTop (fileServe "static/index.html")
<|> routeWith sim [ ("vessel/speed/:speed", method PUT <$> putSpeed)
, ("vessel", method GET <$> getSim)
]
<|> fileServe "static"
routeWith :: a -> [(ByteString, a -> Snap ())] -> Snap ()
routeWith a = route . map f
where
f (r, h) = (r, h a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment