git.iko.soy/typeable/servant
on master help sign in
examples: don't depend on pandoc & servant-pandoc, just serve a markdown file
commita403eee488bc63cda2c8c312c6780c98ad56ff99 authorAlp Mestanogullari <alpmestan@gmail.com> dateSat 9 May 2015, 16:27 (11 years ago) parent616b203
2 files changed+4−29
servant-examples/getting-started/GS10.hs+4−27 servant-examples/servant-examples.cabal−2
servant-examples/getting-started/GS10.hs+4−27
@@ -13,9 +13,6 @@ import Network.HTTP.Types
1313import Network.Wai
1414import Servant
1515import Servant.Docs
16−import Servant.Docs.Pandoc (pandoc)
17−import Text.Pandoc.Options (def, WriterOptions(..))
18−import Text.Pandoc.Writers.HTML (writeHtmlString)
1916import qualified GS3
2017
2118type DocsAPI = GS3.API :<|> Raw
@@ -57,38 +54,18 @@ api = Proxy
5754docsBS :: ByteString
5855docsBS = encodeUtf8
5956 . pack
60− . writeHtmlString opts
61− . pandoc
57+ . markdown
6258 $ docsWithIntros [intro] GS3.api
6359
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!"]
8461
8562server :: Server DocsAPI
8663server = GS3.server :<|> serveDocs
8764
8865 where serveDocs _ respond =
89− respond $ responseLBS ok200 [html] docsBS
66+ respond $ responseLBS ok200 [plain] docsBS
9067
91− html = ("Content-Type", "text/html")
68+ plain = ("Content-Type", "text/plain")
9269
9370app :: Application
9471app = serve api server
servant-examples/servant-examples.cabal−2
@@ -25,13 +25,11 @@ executable getting-started
2525 , http-types
2626 , js-jquery
2727 , lucid
28− , pandoc
2928 , probable
3029 , servant
3130 , servant-docs
3231 , servant-jquery
3332 , servant-lucid
34− , servant-pandoc >= 0.2
3533 , servant-server
3634 , text
3735 , time