Make response logic more dry and lazy
This commit is contained in:
@@ -47,9 +47,10 @@ app :: AppConfig -> Application
|
|||||||
app config req respond =
|
app config req respond =
|
||||||
case path of
|
case path of
|
||||||
[] -> respond =<< responseLBS status200 [json] <$> (printTables =<< conn)
|
[] -> respond =<< responseLBS status200 [json] <$> (printTables =<< conn)
|
||||||
[table] -> respond =<< if verb == methodOptions
|
[table] -> respond =<< (<$>) (responseLBS status200 [json])
|
||||||
then responseLBS status200 [json] <$> (printColumns table =<< conn)
|
( if verb == methodOptions
|
||||||
else responseLBS status200 [json] <$> (selectWhere table qq =<< conn)
|
then printColumns table =<< conn
|
||||||
|
else selectWhere table qq =<< conn )
|
||||||
_ -> respond $ responseLBS status404 [] ""
|
_ -> respond $ responseLBS status404 [] ""
|
||||||
where
|
where
|
||||||
path = pathInfo req
|
path = pathInfo req
|
||||||
|
|||||||
Reference in New Issue
Block a user