Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Documentation
Url-template type.
type family UrlOf a :: Type where ... Source #
Converts route type to URL function
UrlOf (Send method m a) = Url | |
UrlOf (Query name value -> b) = Query name value -> UrlOf b | |
UrlOf (Optional name value -> b) = Optional name value -> UrlOf b | |
UrlOf (Capture name value -> b) = Capture name value -> UrlOf b | |
UrlOf (QueryFlag name -> b) = QueryFlag name -> UrlOf b | |
UrlOf (Header name value -> b) = UrlOf b | |
UrlOf (OptionalHeader name value -> b) = UrlOf b | |
UrlOf (Body media value -> b) = UrlOf b | |
UrlOf (Cookie value -> b) = UrlOf b | |
UrlOf (PathInfo -> b) = UrlOf b | |
UrlOf (FullPathInfo -> b) = UrlOf b | |
UrlOf (RawRequest -> b) = UrlOf b | |
UrlOf (IsSecure -> b) = UrlOf b | |
UrlOf (a, b) = (UrlOf a, UrlOf b) | |
UrlOf (a, b, c) = (UrlOf a, UrlOf b, UrlOf c) | |
UrlOf (a, b, c, d) = (UrlOf a, UrlOf b, UrlOf c, UrlOf d) | |
UrlOf (a, b, c, d, e) = (UrlOf a, UrlOf b, UrlOf c, UrlOf d, UrlOf e) | |
UrlOf (a, b, c, d, e, f) = (UrlOf a, UrlOf b, UrlOf c, UrlOf d, UrlOf e, UrlOf f) | |
UrlOf (a :| b) = UrlOf a :| UrlOf b |
Converts server to safe url. We can use it to generate safe URL constructors to be used in HTML templates An example of how we can create safe URL's. Note that order of URL's should be the same as in server definition:
type GreetingRoute = Get Html type BlogPostRoute = Optional "id" BlogPostId -> Get Html type ListPostsRoute = Get Html data Routes = Routes { greeting :: GreetingRoute , blogPost :: BlogPostRoute , listPosts :: ListPostsRoute } -- URLs data Urls = Urls { greeting :: UrlOf GreetingRoute , blogPost :: UrlOf BlogPostRoute , listPosts :: UrlOf ListPostsRoute } {\-| Site URL's URL's should be listed in the same order as they appear in the server -\} urls :: Urls urls = Urls{..} where greeting :| blogPost :| listPosts toUrl (server undefined)
Instances
ToUrl Url Source # | |
(ToUrl a, ToUrl b) => ToUrl (a :| b) Source # | |
(KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Capture sym a -> b) Source # | |
(KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Optional sym a -> b) Source # | |
(KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Query sym a -> b) Source # | |
(KnownSymbol sym, ToUrl b) => ToUrl (QueryFlag sym -> b) Source # | |
(ToUrl a, ToUrl b) => ToUrl (a, b) Source # | |
(ToUrl a, ToUrl b, ToUrl c) => ToUrl (a, b, c) Source # | |
(ToUrl a, ToUrl b, ToUrl c, ToUrl d) => ToUrl (a, b, c, d) Source # | |