git.iko.soy/typeable/http-api-data
on master help sign in
Add comments
ce7887eCatherine Galkina
Web/HttpApiData/Internal.hs+15
@@ -284,16 +284,31 @@ parseBoundedTextData = parseMaybeTextData (flip lookup values . T.toLower)
284 where
284 where
285 values = map (showTextData &&& id) [minBound..maxBound]
285 values = map (showTextData &&& id) [minBound..maxBound]
286
286
287+-- | /Case insensitive/.
288+--
289+-- Parse values case insensitively based on @'ToHttpApiData'@ instance.
290+-- Uses @'toUrlPiece'@ to get possible values.
291+--
287parseBoundedUrlPiece :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
292parseBoundedUrlPiece :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
288parseBoundedUrlPiece = parseMaybeTextData (flip lookup values . T.toLower)
293parseBoundedUrlPiece = parseMaybeTextData (flip lookup values . T.toLower)
289 where
294 where
290 values = map (toUrlPiece &&& id) [minBound..maxBound]
295 values = map (toUrlPiece &&& id) [minBound..maxBound]
291
296
297+-- | /Case insensitive/.
298+--
299+-- Parse values case insensitively based on @'ToHttpApiData'@ instance.
300+-- Uses @'toQueryParam'@ to get possible values.
301+--
292parseBoundedQueryParam :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
302parseBoundedQueryParam :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
293parseBoundedQueryParam = parseMaybeTextData (flip lookup values . T.toLower)
303parseBoundedQueryParam = parseMaybeTextData (flip lookup values . T.toLower)
294 where
304 where
295 values = map (toQueryParam &&& id) [minBound..maxBound]
305 values = map (toQueryParam &&& id) [minBound..maxBound]
296
306
307+-- | /Case insensitive/.
308+--
309+-- Parse values case insensitively based on @'ToHttpApiData'@ instance.
310+-- Uses @'toHeader'@ to get possible values.
311+--
297parseBoundedHeader :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
312parseBoundedHeader :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
298parseBoundedHeader = parseMaybeTextData (flip lookup values . T.toLower)
313parseBoundedHeader = parseMaybeTextData (flip lookup values . T.toLower)
299 where
314 where