Skip to content

Instantly share code, notes, and snippets.

@jaspervdj
Created May 16, 2011 13:56
Show Gist options
  • Save jaspervdj/974481 to your computer and use it in GitHub Desktop.
Save jaspervdj/974481 to your computer and use it in GitHub Desktop.
-- | This is a Haskell implementation of the benchmark published at:
--
-- <http://www.ostinelli.net/a-comparison-between-misultin-mochiweb-cowboy-nodejs-and-tornadoweb/>
--
-- It is pretty fast as well. It uses WAI and the Warp server. I didn't really
-- bother with using any web framework, since it's such a small benchmark.
--
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad (join)
import Data.Monoid (mappend)
import Blaze.ByteString.Builder.ByteString (fromByteString)
import Network.Wai (Application, Request (..), Response (..))
import Network.Wai.Handler.Warp (run)
import Network.HTTP.Types (statusOK)
application :: Application
application query = return $ ResponseBuilder statusOK headers $ case value of
Just v -> fromByteString "<http_test><value>" `mappend`
fromByteString v `mappend` fromByteString "</value></http_test>"
Nothing -> fromByteString
"<http_test><error>no value specified</error></http_test>"
where
value = join $ lookup "value" (queryString query)
headers = [("Content-Type", "text/xml")]
main :: IO ()
main = run 8000 application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment