Fix where clause, add count in headers

This commit is contained in:
Joe Nelson
2014-08-03 11:26:02 -07:00
parent c278a78edf
commit eb126ab49f
2 changed files with 17 additions and 9 deletions
+8 -2
View File
@@ -70,12 +70,11 @@ app config req respond = do
([table], "GET") ->
if range == Just emptyRange
then return $ responseLBS status416 [] "HTTP Range error"
else responseLBS status200 [json] . rrBody <$>
else respondWithRangedResult <$>
(getRows (show ver) (unpack table) qq range =<< conn)
(_, _) ->
return $ responseLBS status404 [] ""
respond $ either sqlErrorHandler id r
where
@@ -87,6 +86,13 @@ app config req respond = do
ver = fromMaybe 1 $ requestedVersion (requestHeaders req)
range = requestedRange (requestHeaders req)
respondWithRangedResult :: RangedResult -> Response
respondWithRangedResult rr =
responseLBS status206 [json, ("Content-Range", "*/" <> (BS.pack . show . rrTotal) rr)] (rrBody rr)
where
json = (hContentType, "application/json")
requestedVersion :: RequestHeaders -> Maybe Int
requestedVersion hdrs =
case verStr of