[Fencommits] fenserve: make the URI for a potion be /potion/EXPR instead of /potion?exp=EXPR
Benja Fallenstein
benja.fallenstein at gmail.com
Wed Jun 20 02:19:53 EEST 2007
Mon Jun 18 17:57:49 EEST 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* make the URI for a potion be /potion/EXPR instead of /potion?exp=EXPR
diff -rN -u old-fenserve-1/fendata/Main.hs new-fenserve-1/fendata/Main.hs
--- old-fenserve-1/fendata/Main.hs 2007-06-20 02:19:53.000000000 +0300
+++ new-fenserve-1/fendata/Main.hs 2007-06-20 02:19:53.000000000 +0300
@@ -30,16 +30,15 @@
evaluate x = System.IO.Unsafe.unsafePerformIO $ Control.Exception.catch
(Control.Exception.evaluate (length (show x) `seq` Right x))
- (\e -> return $ Left e)
-
+ (\e -> return $ Left $ "Internal server error: " ++ show e)
+
page path _ content = h (path :: [String]) GET $ ok $ \() () -> respond $
- case evaluate (html content) of
- Right s -> s; Left e -> "Internal server error: " ++ show e
+ either id id $ evaluate (html content)
runPost path m = h (path :: [String]) POST $ seeOther $ \() () ->
case evaluate (runState m ?state) of
Right (uri,state') -> put state' >> respond (uri, uri)
- Left e -> respond ("", "Internal server error: " ++ show e)
+ Left e -> respond ("", e)
app = multi
[ page [""] "Welcome to Fenlight!"
@@ -99,8 +98,9 @@
, for fs $ \f -> ( fieldName $ getField f
, Exp "getField" ( f, Exp "var" $ I (0::Int) )))))
- , page ["potion"] "Potion"
- ( renderExp getPotion $ readExp $ lookE "exp"
- , hr
- , renderValues $ runExp [] $ readExp $ lookE "exp" )
+ , h (Prefix ["potion"]) GET $ ok $ \[s] () -> respond $
+ either id id $ evaluate $ html $ let exp = readExp s in
+ ( renderExp getPotion exp
+ , hr
+ , renderValues $ runExp [] exp )
]
More information about the Fencommits
mailing list