diff --git a/src/Application.hs b/src/Application.hs index b470cbe..22fd4e6 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -8,7 +8,7 @@ import Views import Control.Monad.IO.Class (liftIO) import Text.Printf (printf) -import Data.Aeson +import Data.Aeson hiding (json) import Data.Monoid import Data.Text (pack, unpack) import Data.Text.Lazy.Encoding (decodeUtf8) @@ -40,7 +40,7 @@ app url' table = do logStr (printf "Resolved %s -> %s" name url) redirect (pack url) - post root $ do + post "/" $ do url <- fmap unpack <$> param "url" case url of Nothing -> html (render $ message "bad request") @@ -57,7 +57,6 @@ app url' table = do Just url -> do name <- liftIO (insert table url) logStr (printf "Registered %s -> %s " url name) - let json = object [ "link" .= pack (url' <> name) - , "name" .= name - , "original" .= url ] - text (toStrict $ decodeUtf8 $ encode json) + json $ object [ "link" .= pack (url' <> name) + , "name" .= name + , "original" .= url ]