-- Example:
--
-- > {-# LANGUAGE OverloadedStrings #-}
+-- > {-# LANGUAGE QuasiQuotes #-}
-- > module Main where
-- > import Network.HTTP.Lucu
-- >
-- > helloWorld :: ResourceDef
-- > helloWorld = emptyResource {
-- > resGet
--- > = Just $ do setContentType $ parseMIMEType "text/plain"
+-- > = Just $ do setContentType [mimeType| text/plain |]
-- > putChunk "Hello, world!"
-- > }
runHttpd ∷ Config → ResTree → [FallbackHandler] → IO ()
{-# LANGUAGE
OverloadedStrings
+ , QuasiQuotes
, UnicodeSyntax
#-}
import Control.Applicative
helloWorld
= emptyResource {
resGet
- = Just $ do setContentType $ parseMIMEType "text/hello"
+ = Just $ do setContentType [mimeType| text/hello |]
putChunk "Hello, "
putChunk "World!\n"
putChunks =≪ Lazy.pack <$> getRemoteAddr'
= Just $ do str1 ← getChunk 3
str2 ← getChunk 3
str3 ← getChunk 3
- setContentType $ parseMIMEType "text/hello"
+ setContentType [mimeType| text/hello |]
putChunks $ Lazy.fromChunks ["[", str1, " - ", str2, "#", str3, "]"]
}
{-# LANGUAGE
OverloadedStrings
, PackageImports
+ , QuasiQuotes
, UnicodeSyntax
#-}
import Control.Applicative
helloWorld
= emptyResource {
resGet
- = Just $ do setContentType $ parseMIMEType "text/plain"
+ = Just $ do setContentType [mimeType| text/plain |]
putChunk "getRemoteCertificate = "
cert ← do cert ← getRemoteCertificate
case cert of