mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-23 23:43:44 +03:00
a8f1af21ca
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8179 GitOrigin-RevId: 66a1c8d26ef2a4eecba8a49f906582e5f9eb871c
29 lines
607 B
Haskell
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
|