The http-pony package

[Tags:bsd3, library]

[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5
Change log ChangeLog.md
Dependencies base (>=4.8 && <5), bytestring (>=0.10), exceptions (>=0.8.3), network (>=2.6), pipes (>=4.1), pipes-network (>=0.6), pipes-safe (>=2.2), transformers (>=0.4) [details]
License BSD3
Author Jinjing Wang
Maintainer nfjinjing@gmail.com
Category Network
Home page https://github.com/nfjinjing/http-pony
Uploaded Sat Oct 15 17:31:37 UTC 2016 by JinjingWang
Distributions NixOS:0.1.0.5
Downloads 135 total (2 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2016-10-15 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for http-pony

Readme for http-pony-0.1.0.5

Teaser

Let's write a hello world app.

{-# LANGUAGE OverloadedStrings #-}

module Hello where

import Pipes (yield)

hello _ = pure (("HTTP/1.1 200 OK", []), yield "hello world\n")

Note, we are not importing any interface!

If we take a closer look at the type of hello:

Prelude Hello> :t hello 
hello
  :: (Applicative f, Data.String.IsString a, Data.String.IsString t,
      Monad m) =>
    t2 -> f ((t, [t1]), Pipes.Internal.Proxy x' x () a m ())

This is a pure app!

Shall we run it?

{-# LANGUAGE OverloadedStrings #-}

module RunHello where

import Hello (hello)
import Network.HTTP.Pony.Serve (run)
import Network.HTTP.Pony.Transformer.HTTP (http)
import Pipes.Safe (runSafeT)

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

Test it:

# the above files are mirrored in `./test`
runghc -isrc -itest test/RunHello.hs

# open another terminal
curl localhost:8080 -i

# output:

> HTTP/1.1 200 OK
>
> hello world

wow ~

Exercise: write a tcp cat