diff --git a/aws-lambda-haskell-runtime.cabal b/aws-lambda-haskell-runtime.cabal index 7fd44db..da3e249 100644 --- a/aws-lambda-haskell-runtime.cabal +++ b/aws-lambda-haskell-runtime.cabal @@ -58,7 +58,7 @@ library QuasiQuotes ghc-options: -Wall -optP-Wno-nonportable-include-path -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat -Widentities -Wredundant-constraints -Wmissing-export-lists -Wpartial-fields -fhide-source-paths -freverse-errors build-depends: - aeson + aeson >2 , base >=4.7 && <5 , bytestring , case-insensitive diff --git a/src/Aws/Lambda/Runtime/ALB/Types.hs b/src/Aws/Lambda/Runtime/ALB/Types.hs index 16117e7..c97765d 100644 --- a/src/Aws/Lambda/Runtime/ALB/Types.hs +++ b/src/Aws/Lambda/Runtime/ALB/Types.hs @@ -27,6 +27,7 @@ import Data.Aeson ) import Data.Aeson.Types (Parser) import qualified Data.Aeson.Types as T +import qualified Data.Aeson.Key as K import qualified Data.CaseInsensitive as CI import Data.HashMap.Strict (HashMap) import Data.Text (Text) @@ -59,7 +60,7 @@ instance FromJSON body => FromJSON (ALBRequest body) where parseJSON = parseALBRequest parseObjectFromStringField -- We need this because API Gateway is going to send us the payload as a JSON string -parseObjectFromStringField :: FromJSON a => Object -> Text -> Parser (Maybe a) +parseObjectFromStringField :: FromJSON a => Object -> T.Key -> Parser (Maybe a) parseObjectFromStringField obj fieldName = do fieldContents <- obj .: fieldName case fieldContents of @@ -70,7 +71,7 @@ parseObjectFromStringField obj fieldName = do Null -> pure Nothing other -> T.typeMismatch "String or Null" other -parseALBRequest :: (Object -> Text -> Parser (Maybe body)) -> Value -> Parser (ALBRequest body) +parseALBRequest :: (Object -> T.Key -> Parser (Maybe body)) -> Value -> Parser (ALBRequest body) parseALBRequest bodyParser (Object v) = ALBRequest <$> v .: "path" @@ -167,5 +168,5 @@ mkALBResponse code headers payload = headerToPair :: Header -> T.Pair headerToPair (cibyte, bstr) = k .= v where - k = (T.decodeUtf8 . CI.original) cibyte + k = (K.fromText . T.decodeUtf8 . CI.original) cibyte v = T.decodeUtf8 bstr diff --git a/src/Aws/Lambda/Runtime/APIGateway/Types.hs b/src/Aws/Lambda/Runtime/APIGateway/Types.hs index 4c3acb9..d4e83ee 100644 --- a/src/Aws/Lambda/Runtime/APIGateway/Types.hs +++ b/src/Aws/Lambda/Runtime/APIGateway/Types.hs @@ -29,6 +29,7 @@ import Data.Aeson (.:?) ) import Data.Aeson.Types (Parser) +import qualified Data.Aeson.Key as K import qualified Data.Aeson.Types as T import qualified Data.CaseInsensitive as CI import Data.HashMap.Strict (HashMap) @@ -70,7 +71,7 @@ instance FromJSON body => FromJSON (ApiGatewayRequest body) where parseJSON = parseApiGatewayRequest parseObjectFromStringField -- We need this because API Gateway is going to send us the payload as a JSON string -parseObjectFromStringField :: FromJSON a => Object -> Text -> Parser (Maybe a) +parseObjectFromStringField :: FromJSON a => Object -> T.Key -> Parser (Maybe a) parseObjectFromStringField obj fieldName = do fieldContents <- obj .: fieldName case fieldContents of @@ -81,7 +82,7 @@ parseObjectFromStringField obj fieldName = do Null -> pure Nothing other -> T.typeMismatch "String or Null" other -parseApiGatewayRequest :: (Object -> Text -> Parser (Maybe body)) -> Value -> Parser (ApiGatewayRequest body) +parseApiGatewayRequest :: (Object -> T.Key -> Parser (Maybe body)) -> Value -> Parser (ApiGatewayRequest body) parseApiGatewayRequest bodyParser (Object v) = ApiGatewayRequest <$> v .: "resource" @@ -215,5 +216,5 @@ mkApiGatewayResponse code headers payload = headerToPair :: Header -> T.Pair headerToPair (cibyte, bstr) = k .= v where - k = (T.decodeUtf8 . CI.original) cibyte + k = (K.fromText . T.decodeUtf8 . CI.original) cibyte v = T.decodeUtf8 bstr