Safe Haskell | None |
---|---|
Language | Haskell2010 |
Use your Rowdy route definitions with Yesod web applications.
Synopsis
- type Dsl = RouteDsl String PathPiece Endpoint
- toYesod :: Dsl () -> [ResourceTree String]
- get :: String -> Dsl ()
- put :: String -> Dsl ()
- post :: String -> Dsl ()
- delete :: String -> Dsl ()
- doVerb :: Verb -> String -> Dsl ()
- subsite :: String -> String -> String -> Dsl ()
- capture :: forall typ. Typeable typ => PathPiece
- captureP :: forall typ. Typeable typ => Proxy typ -> PathPiece
- resource :: String -> [String -> Dsl ()] -> Dsl ()
- attr :: String -> Dsl () -> Dsl ()
- (/!) :: String -> Dsl () -> Dsl ()
- (!) :: Dsl () -> String -> Dsl ()
- (//) :: capture -> RouteDsl nest capture endpoint () -> RouteDsl nest capture endpoint ()
- (/:) :: nest -> RouteDsl nest capture endpoint () -> RouteDsl nest capture endpoint ()
- data Endpoint
- data PathPiece
- data Type where
- data Verb
Documentation
type Dsl = RouteDsl String PathPiece Endpoint Source #
We specialize the RouteDsl
type to this as a shorthand.
toYesod :: Dsl () -> [ResourceTree String] Source #
Convert a RouteDsl
into a representation that Yesod can use.
mkYesod App $ toYesod $ do get RootR "users" // do resource UserIndex [get, post] -- etc...
GHC freaks out if you try to use a type defined in the same module as the route. Ensure that all types you use in the route are defined in an imported module.
Since: 0.0.1.0
get :: String -> Dsl () Source #
We support the most common HTTP verbs. Each of get
, put
, post
, and
delete
are given a String
that represents the resource they are acting
for. The generated route type uses that resource as a constructor. The
generated dispatcher expects to see functions with the lowercase verb as
a prefix to the resource name. As an example:
get HelloR
Will create a route type HelloR
and expect a handler getHelloR
to be
defined.
Since: 0.0.1.0
put :: String -> Dsl () Source #
We support the most common HTTP verbs. Each of get
, put
, post
, and
delete
are given a String
that represents the resource they are acting
for. The generated route type uses that resource as a constructor. The
generated dispatcher expects to see functions with the lowercase verb as
a prefix to the resource name. As an example:
get HelloR
Will create a route type HelloR
and expect a handler getHelloR
to be
defined.
Since: 0.0.1.0
post :: String -> Dsl () Source #
We support the most common HTTP verbs. Each of get
, put
, post
, and
delete
are given a String
that represents the resource they are acting
for. The generated route type uses that resource as a constructor. The
generated dispatcher expects to see functions with the lowercase verb as
a prefix to the resource name. As an example:
get HelloR
Will create a route type HelloR
and expect a handler getHelloR
to be
defined.
Since: 0.0.1.0
delete :: String -> Dsl () Source #
We support the most common HTTP verbs. Each of get
, put
, post
, and
delete
are given a String
that represents the resource they are acting
for. The generated route type uses that resource as a constructor. The
generated dispatcher expects to see functions with the lowercase verb as
a prefix to the resource name. As an example:
get HelloR
Will create a route type HelloR
and expect a handler getHelloR
to be
defined.
Since: 0.0.1.0
doVerb :: Verb -> String -> Dsl () Source #
Create an endpoint with the given named resource and verb.
Since: 0.0.1.0
subsite :: String -> String -> String -> Dsl () Source #
Create a subsite with the given name
, type
, and accessor function name
to get the underlying application.
Since: 0.0.1.0
capture :: forall typ. Typeable typ => PathPiece Source #
Capture a dynamic path piece and parse it as the provided type. This
function is intended to be used with the TypeApplications
language
extension.
"users" // do resource UserIndexR [get, post] capture @UserId $ do resource UserR [get, put, delete] "posts" // do resource PostR [get, post]
Since: 0.0.1.0
attr :: String -> Dsl () -> Dsl () Source #
Attach a route attribute to every element in the given DSL.
Since: 0.0.1.0
(!) :: Dsl () -> String -> Dsl () infixl 8 Source #
Provide an inline attribute to the given route.
get HelloR ! "friendly"
(//) :: capture -> RouteDsl nest capture endpoint () -> RouteDsl nest capture endpoint () infixr 5 #
An infix operator for pathComponent
.
Since: rowdy-0.0.1.0
(/:) :: nest -> RouteDsl nest capture endpoint () -> RouteDsl nest capture endpoint () infixr 7 #
An infix operator alias for nest
.
Since: rowdy-0.0.1.0
The type of things that can affect a path.
Literal String | Static string literals. |
Capture Type | Dynamic captures. |
Attr String | Route attributes. Not technically part of the path, but applies to everything below it in the tree. |
A value containing a Proxy
of some Haskell type.
The HTTP verbs.