refactor: Remove GHC.Show instances from JSPath module
This commit is contained in:
@@ -50,7 +50,7 @@ import System.Environment (getEnvironment)
|
|||||||
import System.Posix.Types (FileMode)
|
import System.Posix.Types (FileMode)
|
||||||
|
|
||||||
import PostgREST.Config.JSPath (JSPath, JSPathExp (..),
|
import PostgREST.Config.JSPath (JSPath, JSPathExp (..),
|
||||||
pRoleClaimKey)
|
dumpJSPath, pRoleClaimKey)
|
||||||
import PostgREST.Config.Proxy (Proxy (..),
|
import PostgREST.Config.Proxy (Proxy (..),
|
||||||
isMalformedProxyUri, toURI)
|
isMalformedProxyUri, toURI)
|
||||||
import PostgREST.DbStructure.Identifiers (QualifiedIdentifier, dumpQi,
|
import PostgREST.DbStructure.Identifiers (QualifiedIdentifier, dumpQi,
|
||||||
@@ -100,10 +100,10 @@ data LogLevel = LogCrit | LogError | LogWarn | LogInfo
|
|||||||
|
|
||||||
dumpLogLevel :: LogLevel -> Text
|
dumpLogLevel :: LogLevel -> Text
|
||||||
dumpLogLevel = \case
|
dumpLogLevel = \case
|
||||||
LogCrit -> "crit"
|
LogCrit -> "crit"
|
||||||
LogError -> "error"
|
LogError -> "error"
|
||||||
LogWarn -> "warn"
|
LogWarn -> "warn"
|
||||||
LogInfo -> "info"
|
LogInfo -> "info"
|
||||||
|
|
||||||
data OpenAPIMode = OAFollowPriv | OAIgnorePriv | OADisabled
|
data OpenAPIMode = OAFollowPriv | OAIgnorePriv | OADisabled
|
||||||
deriving Eq
|
deriving Eq
|
||||||
@@ -138,7 +138,7 @@ toText conf =
|
|||||||
,("db-embed-default-join", q . dumpJoin . configDbEmbedDefaultJoin)
|
,("db-embed-default-join", q . dumpJoin . configDbEmbedDefaultJoin)
|
||||||
,("db-use-legacy-gucs", T.toLower . show . configDbUseLegacyGucs)
|
,("db-use-legacy-gucs", T.toLower . show . configDbUseLegacyGucs)
|
||||||
,("jwt-aud", toS . encode . maybe "" toJSON . configJwtAudience)
|
,("jwt-aud", toS . encode . maybe "" toJSON . configJwtAudience)
|
||||||
,("jwt-role-claim-key", q . T.intercalate mempty . fmap show . configJwtRoleClaimKey)
|
,("jwt-role-claim-key", q . T.intercalate mempty . fmap dumpJSPath . configJwtRoleClaimKey)
|
||||||
,("jwt-secret", q . toS . showJwtSecret)
|
,("jwt-secret", q . toS . showJwtSecret)
|
||||||
,("jwt-secret-is-base64", T.toLower . show . configJwtSecretIsBase64)
|
,("jwt-secret-is-base64", T.toLower . show . configJwtSecretIsBase64)
|
||||||
,("log-level", q . dumpLogLevel . configLogLevel)
|
,("log-level", q . dumpLogLevel . configLogLevel)
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
{-|
|
|
||||||
Module : PostgREST.Types
|
|
||||||
Description : PostgREST common types and functions used by the rest of the modules
|
|
||||||
-}
|
|
||||||
{-# LANGUAGE DuplicateRecordFields #-}
|
|
||||||
|
|
||||||
module PostgREST.Config.JSPath
|
module PostgREST.Config.JSPath
|
||||||
( JSPath
|
( JSPath
|
||||||
, JSPathExp(..)
|
, JSPathExp(..)
|
||||||
|
, dumpJSPath
|
||||||
, pRoleClaimKey
|
, pRoleClaimKey
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@@ -16,8 +11,6 @@ import Data.Either.Combinators (mapLeft)
|
|||||||
import Text.ParserCombinators.Parsec ((<?>))
|
import Text.ParserCombinators.Parsec ((<?>))
|
||||||
import Text.Read (read)
|
import Text.Read (read)
|
||||||
|
|
||||||
import qualified GHC.Show (show)
|
|
||||||
|
|
||||||
import Protolude hiding (toS)
|
import Protolude hiding (toS)
|
||||||
import Protolude.Conv (toS)
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
@@ -30,10 +23,10 @@ data JSPathExp
|
|||||||
= JSPKey Text
|
= JSPKey Text
|
||||||
| JSPIdx Int
|
| JSPIdx Int
|
||||||
|
|
||||||
instance Show JSPathExp where
|
dumpJSPath :: JSPathExp -> Text
|
||||||
-- TODO: this needs to be quoted properly for special chars
|
-- TODO: this needs to be quoted properly for special chars
|
||||||
show (JSPKey k) = "." <> show k
|
dumpJSPath (JSPKey k) = "." <> show k
|
||||||
show (JSPIdx i) = "[" <> show i <> "]"
|
dumpJSPath (JSPIdx i) = "[" <> show i <> "]"
|
||||||
|
|
||||||
-- Used for the config value "role-claim-key"
|
-- Used for the config value "role-claim-key"
|
||||||
pRoleClaimKey :: Text -> Either Text JSPath
|
pRoleClaimKey :: Text -> Either Text JSPath
|
||||||
|
|||||||
Reference in New Issue
Block a user