git.iko.soy/typeable/servant
on master help sign in
examples: don't depend on pandoc & servant-pandoc, just serve a markdown file
a403eeeAlp Mestanogullari
servant-examples/getting-started/GS10.hs+4−27
@@ -13,9 +13,6 @@ import Network.HTTP.Types
13import Network.Wai
13import Network.Wai
14import Servant
14import Servant
15import Servant.Docs
15import Servant.Docs
16−import Servant.Docs.Pandoc (pandoc)
17−import Text.Pandoc.Options (def, WriterOptions(..))
18−import Text.Pandoc.Writers.HTML (writeHtmlString)
19import qualified GS3
16import qualified GS3
20
17
21type DocsAPI = GS3.API :<|> Raw
18type DocsAPI = GS3.API :<|> Raw
@@ -57,38 +54,18 @@ api = Proxy
57docsBS :: ByteString
54docsBS :: ByteString
58docsBS = encodeUtf8
55docsBS = encodeUtf8
59 . pack
56 . pack
60− . writeHtmlString opts
57+ . markdown
61− . pandoc
62 $ docsWithIntros [intro] GS3.api
58 $ docsWithIntros [intro] GS3.api
63
59
64− where opts = def { writerHtml5 = True
65− , writerTableOfContents = True
66− , writerHighlight = True
67− , writerStandalone = True
68− , writerTemplate =
69− concat
70− [ "<!DOCTYPE html><html>"
71− , "<head>"
72− , "<meta charset=\"UTF-8\">"
73− , "<title>API Docs - $title$</title>"
74− , "</head>"
75− , "<body>"
76− , "$toc$"
77− , "<hr />"
78− , "$body$"
79− , "</body>"
80− , "</html>"
81− ]
82− }
83− intro = DocIntro "Welcome" ["This is our super webservice's API.", "Enjoy!"]
60+ where intro = DocIntro "Welcome" ["This is our super webservice's API.", "Enjoy!"]
84
61
85server :: Server DocsAPI
62server :: Server DocsAPI
86server = GS3.server :<|> serveDocs
63server = GS3.server :<|> serveDocs
87
64
88 where serveDocs _ respond =
65 where serveDocs _ respond =
89− respond $ responseLBS ok200 [html] docsBS
66+ respond $ responseLBS ok200 [plain] docsBS
90
67
91− html = ("Content-Type", "text/html")
68+ plain = ("Content-Type", "text/plain")
92
69
93app :: Application
70app :: Application
94app = serve api server
71app = serve api server
servant-examples/servant-examples.cabal−2
@@ -25,13 +25,11 @@ executable getting-started
25 , http-types
25 , http-types
26 , js-jquery
26 , js-jquery
27 , lucid
27 , lucid
28− , pandoc
29 , probable
28 , probable
30 , servant
29 , servant
31 , servant-docs
30 , servant-docs
32 , servant-jquery
31 , servant-jquery
33 , servant-lucid
32 , servant-lucid
34− , servant-pandoc >= 0.2
35 , servant-server
33 , servant-server
36 , text
34 , text
37 , time
35 , time