http-pony-serve-wai: Serve a WAI application with http-pony

[ bsd3, library, network ] [ Propose Tags ] [ Report a vulnerability ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4
Change log ChangeLog.md
Dependencies attoparsec (>=0.13), base (>=4.9 && <4.10), blaze-builder (>=0.4.0.2), bytestring (>=0.10), case-insensitive (>=1.2.0.7), http-pony-transformer-http (>=0.1.0.0), http-pony-transformer-startline (>=0.1.0.0), http-types (>=0.9.1), pipes (>=4.1), pipes-bytestring (>=2.1.3), pipes-safe (>=2.2.4), transformers (>=0.5.2), wai (>=3.2.1.1) [details]
License BSD-3-Clause
Author Jinjing Wang
Maintainer nfjinjing@gmail.com
Category Network
Home page https://github.com/nfjinjing/http-pony-serve-wai
Uploaded by JinjingWang at 2016-09-24T08:42:37Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2843 total (11 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-09-24 [all 1 reports]

Readme for http-pony-serve-wai-0.1.0.4

[back to package description]

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.