Permalink
Browse files

updated bird to support execStateT

  • Loading branch information...
Matt Parker
Matt Parker committed Jul 5, 2010
1 parent 6c0e3fa commit 137454fc5c499a4789886bfc7d662d3f221d43ba
Showing with 18 additions and 11 deletions.
  1. +14 −7 README.markdown
  2. +1 −1 bin/bird.hs
  3. +3 −3 bird.cabal
View
@@ -39,20 +39,27 @@ Note: make sure $HOME/.cabal/bin is in your PATH.
import Bird
import Data.String.Utils
- get, post, put, delete :: Request -> IO Reply
- get Request { path = ("howdy":xs) }
- = ok $ "Howdy " ++ (join ", " xs) ++ "!"
+ get, post, put, delete :: Path -> BirdRouter ()
+ get ("howdy":xs) = body $ "Howdy " ++ (join ", " xs) ++ "!"
- get _ = return notFound_
- post _ = return notFound_
- put _ = return notFound_
- delete _ = return notFound_
+ get ["droids"] = do
+ body "Nothing to see here. Move along."
+ status 404
+
+ get _ = status 404
+ post _ = status 404
+ put _ = status 404
+ delete _ = status 404
now:
λ curl http://localhost:3000/howdy/there/pardna
Howdy there, pardna!
+ λ curl http://localhost:3000/droids
+ Nothing to see here. Move along.
+
+
## Notes
This project is *still* in its infancy. Coming features:
View
@@ -43,7 +43,7 @@ mainFile a =
" where \n" ++
" r = envToRequest e\n" ++
" response = do \n" ++
- " reply <- S.execState (matchRequest r) def\n" ++
+ " reply <- S.execStateT (matchRequest r) def\n" ++
" return $ replyToResponse reply\n" ++ "\n" ++
"matchRequest r = \n" ++
View
@@ -1,5 +1,5 @@
Name: bird
-Version: 0.0.6
+Version: 0.0.7
Build-type: Simple
Synopsis: A simple, sinatra-inspired web framework.
Description: Bird is a hack-compatible framework for simple websites.
@@ -18,6 +18,6 @@ Executable bird
hs-source-dirs: bin
library
- build-depends: haskell98, 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.Request, Bird.Reply, Bird.Reply.Codes, Bird.Request.QueryStringParser
+ build-depends: haskell98, 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.Request, Bird.Reply, Bird.Reply.Codes, Bird.Request.QueryStringParser, Bird.BirdRouter
hs-source-dirs: src/

0 comments on commit 137454f

Please sign in to comment.