From e11e2de64c3b0afff93d21dc43fc974cb5248b09 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Mon, 20 Apr 2015 22:17:51 +0200 Subject: [PATCH] Rewrite in a nicer way --- src/Application.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Application.hs b/src/Application.hs index ef53de4..fef719f 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -42,9 +42,10 @@ app runner = do Nothing -> respond notFound post "/short" $ do - (form, _) <- parseForm - case BS.unpack <$> lookup "url" form of - Just url -> do + form <- fmap fst parseForm + case lookup "url" form of + Just url' -> do + let url = BS.unpack url' name <- liftIO (insert table url) logStr (printf "Registered %s -> %s " url name) render done $ object ["link" .= (bindUrl ++ name)]