@@ -23,9 +23,11 @@ newtype Greet = Greet Text
23instance FromJSON Greet
23instance FromJSON Greet
24instance ToJSON Greet
24instance ToJSON Greet
26+-- | A 'Greet' value can be rendered to 'JSON'.
26instance MimeRender JSON Greet where
27instance MimeRender JSON Greet where
27 toByteString Proxy = encodePretty
28 toByteString Proxy = encodePretty
30+-- | A 'Greet' value can be rendered to 'HTML'.
29instance MimeRender HTML Greet where
31instance MimeRender HTML Greet where
30 toByteString Proxy (Greet s) = "<h1>" <> cs s <> "</h1>"
32 toByteString Proxy (Greet s) = "<h1>" <> cs s <> "</h1>"
@@ -74,12 +76,12 @@ intro2 = DocIntro "This title is below the last"
75-- API specification
77-- API specification
76type TestApi =
78type TestApi =
77− -- GET /hello/:name?capital={true, false} returns a Greet as JSON
79+ -- GET /hello/:name?capital={true, false} returns a Greet as JSON or HTML
78 "hello" :> MatrixParam "lang" String :> Capture "name" Text :> QueryParam "capital" Bool :> Get '[JSON, HTML] Greet
80 "hello" :> MatrixParam "lang" String :> Capture "name" Text :> QueryParam "capital" Bool :> Get '[JSON, HTML] Greet
80 -- POST /greet with a Greet as JSON in the request body,
82 -- POST /greet with a Greet as JSON in the request body,
81 -- returns a Greet as JSON
83 -- returns a Greet as JSON
82− :<|> "greet" :> ReqBody '[JSON,HTML] Greet :> Post '[JSON] Greet
84+ :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet
84 -- DELETE /greet/:greetid
86 -- DELETE /greet/:greetid
85 :<|> "greet" :> Capture "greetid" Text :> Delete
87 :<|> "greet" :> Capture "greetid" Text :> Delete