Serve a WAI application with http-pony

Latest on Hackage:

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 to host generated Haddocks.

BSD3 licensed by Jinjing Wang
Maintained by

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
      [("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


  • Streaming response is not implemented.


Revision history for http-pony-serve-wai -- 2016-09-20

  • First version. Released on an unsuspecting world.

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