Created
December 2, 2016 21:33
-
-
Save imalsogreg/465a481e357192c08bc17b6dab64959e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webRoute | |
:: (MonadWidget t m, WR.PathInfo a) | |
=> T.Text -- ^ The part of the URL not related to SPA routing, starting with '/' | |
-> Event t a | |
-> m (Dynamic t (Either T.Text a)) | |
webRoute pathBase aUpdates = do | |
route' encoder decoder aUpdates | |
where | |
-- x = WR.fromPathInfo :: _ | |
encoder u a = u & U.pathL .~ T.encodeUtf8 (pathBase <> WR.toPathInfo a) | |
decoder u = first T.pack . WR.fromPathInfo =<< | |
note (pathBase <> " is a Bad prefix for " <> T.decodeUtf8 (U.serializeURIRef' u)) | |
(BS.stripPrefix (T.encodeUtf8 pathBase) (u ^. U.pathL)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment