bird 0.0.17 → 0.0.18
raw patch · 4 files changed
+41/−6 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Bird.Request.UrlencodedFormParser: parseUrlencodedForm :: String -> [(String, Maybe String)]
Files
- bird.cabal +2/−2
- readme.markdown +20/−0
- src/Bird/Request/UrlencodedFormParser.hs +7/−0
- src/Bird/Translator/Hack.hs +12/−4
bird.cabal view
@@ -1,5 +1,5 @@ Name: bird-Version: 0.0.17+Version: 0.0.18 Build-type: Simple Synopsis: A simple, sinatra-inspired web framework. Description: Bird is a hack-compatible framework for simple websites.@@ -19,5 +19,5 @@ library build-depends: haskell98, MissingH >= 1.1.0.3, mtl >= 1.1.0.2, process, containers, parsec >= 2.1.0.1, bytestring, base >= 4.0 && < 5, hack >= 2009.10.30, hack-handler-happstack, data-default >= 0.2, rallod - exposed-modules: Bird, Bird.Logger, Bird.Config, Bird.Request, Bird.Reply, Bird.Request.QueryStringParser, Bird.BirdResponder, Bird.Translator, Bird.Translator.Hack+ exposed-modules: Bird, Bird.Logger, Bird.Config, Bird.Request, Bird.Reply, Bird.Request.QueryStringParser, Bird.Request.UrlencodedFormParser, Bird.BirdResponder, Bird.Translator, Bird.Translator.Hack hs-source-dirs: src/
readme.markdown view
@@ -48,6 +48,14 @@ body "These aren't the droids you're looking for. Move along." status 404 + post ["jedi"] = do+ name <- param "name"+ teacher <- param "teacher"+ case teacher of + Just "Yoda" -> body "The force is strong with this one!" >> status 201+ _ -> body "Sorry. The force is not with this one." >> status 400 ++ get ("force":xs) = do body $ "May the force be with you " ++ (join ", " xs) ++ "!" @@ -70,6 +78,18 @@ Server: Happstack/0.5.0.2 May the force be with you Han, Chewie!++ + λ curl -i -X POST http://localhost:3000/jedi -d name=Luke -d teacher=Yoda+ + HTTP/1.1 201 Created+ Connection: close+ Content-Type: text/html+ Date: Sat, 21 Aug 2010 21:38:11 GMT+ Server: Happstack/0.5.0.2++ The force is strong with this one!+ λ curl -i http://localhost:3000/droids
+ src/Bird/Request/UrlencodedFormParser.hs view
@@ -0,0 +1,7 @@+module Bird.Request.UrlencodedFormParser(+ parseUrlencodedForm+) where++import Bird.Request.QueryStringParser++parseUrlencodedForm = parseQueryString
src/Bird/Translator/Hack.hs view
@@ -9,7 +9,8 @@ import Bird.Request import Bird.Reply import Bird.Request.QueryStringParser-import Data.ByteString.Lazy.Char8 (pack)+import Bird.Request.UrlencodedFormParser+import Data.ByteString.Lazy.Char8 (pack, unpack) instance BirdReplyTranslator Hack.Response where fromBirdReply r = @@ -26,14 +27,21 @@ Request { verb = hackRequestMethodToBirdRequestMethod $ Hack.requestMethod e , path = split '/' $ Hack.pathInfo e- , params = parseQueryString $ Hack.queryString e- , rawRequestUri = (Hack.pathInfo e) ++ maybeQueryString e+ , params = parsedParams+ , rawRequestUri = (Hack.pathInfo e) ++ maybeQueryString } where- maybeQueryString e =+ maybeQueryString = if Hack.queryString e /= "" then "?" ++ Hack.queryString e else ""+ parsedQueryString = parseQueryString (Hack.queryString e)+ parsedUrlencodedForm = + if (Hack.requestMethod e == Hack.POST || Hack.requestMethod e == Hack.PUT) && + lookup "Content-Type" (Hack.http e) == Just "application/x-www-form-urlencoded"+ then parseQueryString (unpack $ Hack.hackInput e)+ else []+ parsedParams = parsedQueryString ++ parsedUrlencodedForm hackRequestMethodToBirdRequestMethod rm =