Accurate range response headers
This commit is contained in:
@@ -91,8 +91,10 @@ respondWithRangedResult rr =
|
|||||||
responseLBS status206 [
|
responseLBS status206 [
|
||||||
json,
|
json,
|
||||||
("Content-Range",
|
("Content-Range",
|
||||||
"0-" <> (BS.pack . show . rrTo) rr <> "/"
|
(BS.pack . show . rrFrom ) rr <> "-"
|
||||||
<> (BS.pack . show . rrTotal) rr)
|
<> (BS.pack . show . rrTo ) rr <> "/"
|
||||||
|
<> (BS.pack . show . rrTotal) rr
|
||||||
|
)
|
||||||
] (rrBody rr)
|
] (rrBody rr)
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|||||||
+5
-1
@@ -41,9 +41,13 @@ getRows schema table qq range conn = do
|
|||||||
|
|
||||||
return $ case r of
|
return $ case r of
|
||||||
[[total, limited_total, json]] ->
|
[[total, limited_total, json]] ->
|
||||||
RangedResult 0 (fromSql limited_total) (fromSql total) (fromSql json)
|
RangedResult offset (offset + fromSql limited_total - 1)
|
||||||
|
(fromSql total) (fromSql json)
|
||||||
_ -> RangedResult 0 0 0 ""
|
_ -> RangedResult 0 0 0 ""
|
||||||
|
|
||||||
|
where
|
||||||
|
offset = fromMaybe 0 $ R.offset <$> range
|
||||||
|
|
||||||
whereClause :: Net.Query -> QuotedSql
|
whereClause :: Net.Query -> QuotedSql
|
||||||
whereClause qs =
|
whereClause qs =
|
||||||
if null qs then ("", []) else (" where ", []) <> conjunction
|
if null qs then ("", []) else (" where ", []) <> conjunction
|
||||||
|
|||||||
Reference in New Issue
Block a user