git.iko.soy/typeable/http-api-data
on master help sign in
Add functions to parse bounded data based on ToHttpApiData instance
cf58f99Catherine Galkina
Web/HttpApiData/Internal.hs+15
@@ -284,6 +284,21 @@ 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+parseBoundedUrlPiece :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
288+parseBoundedUrlPiece = parseMaybeTextData (flip lookup values . T.toLower)
289+ where
290+ values = map (toUrlPiece &&& id) [minBound..maxBound]
291+
292+parseBoundedQueryParam :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
293+parseBoundedQueryParam = parseMaybeTextData (flip lookup values . T.toLower)
294+ where
295+ values = map (toQueryParam &&& id) [minBound..maxBound]
296+
297+parseBoundedHeader :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
298+parseBoundedHeader = parseMaybeTextData (flip lookup values . T.toLower)
299+ where
300+ values = map (decodeUtf8 . toHeader &&& id) [minBound..maxBound]
301+
287-- | Parse URL piece using @'Read'@ instance.
302-- | Parse URL piece using @'Read'@ instance.
288--
303--
289-- Use for types which do not involve letters:
304-- Use for types which do not involve letters: