http-pony-serve-wai

Serve a WAI application with http-pony https://github.com/nfjinjing/http-pony-serve-wai

Latest on Hackage:0.1.0.4

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Jinjing Wang
Maintained by nfjinjing@gmail.com

Starting from a WAI app

{-# LANGUAGE OverloadedStrings #-}

module Hello where

import           Network.HTTP.Pony.Serve.Wai (fromWAI)
import qualified Network.HTTP.Types as HTTP
import qualified Network.Wai as Wai

waiApp :: Wai.Application
waiApp request respond = do

  respond $ Wai.responseLBS
      HTTP.status200
      [("Content-Type", "text/plain")]
      "Hello, WAI!"

hello = fromWAI waiApp

Serve with pony

{-# LANGUAGE OverloadedStrings #-}

module RunHello where

import Network.HTTP.Pony.Serve (run)
import Network.HTTP.Pony.Transformer.HTTP (http)
import Network.HTTP.Pony.Transformer.StartLine (startLine)
import Network.HTTP.Pony.Transformer.CaseInsensitive (caseInsensitive)

import Pipes.Safe (runSafeT)
import Hello (hello)

main :: IO ()
main = ( runSafeT
          . run "localhost" "8080"
          . http
          . startLine
          . caseInsensitive
        ) hello

Note

  • Streaming response is not implemented.

Changes

Revision history for http-pony-serve-wai

0.1.0.0 -- 2016-09-20

  • First version. Released on an unsuspecting world.

0.1.0.3

  • Use http-types to decode uri, this release should be compatible with most WAI apps that do not use streaming response.
comments powered byDisqus