graphql-engine/server/src-lib/Network/URI/Extended.hs
Tom Harding a8f1af21ca Remove incoherent pragmas in Network.URI.Extended
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8179
GitOrigin-RevId: 66a1c8d26ef2a4eecba8a49f906582e5f9eb871c
2023-03-03 06:02:57 +00:00

29 lines
607 B
Haskell

{-# OPTIONS_GHC -fno-warn-orphans #-}
module Network.URI.Extended
( module Network.URI,
)
where
import Data.Aeson
import Data.Aeson.Types
import Data.Hashable
import Data.Text qualified as T
import Hasura.Prelude
import Network.URI
instance FromJSON URI where
parseJSON (String uri) = do
let mUrl = parseURI $ T.unpack uri
onNothing mUrl (fail "not a valid URI")
parseJSON _ = fail "not a valid URI"
instance ToJSON URI where
toJSON = String . tshow
instance ToJSONKey URI where
toJSONKey = toJSONKeyText tshow
instance Hashable URI where
hashWithSalt i = hashWithSalt i . tshow