Skip to content

Commit

Permalink
Change raw-media-types to accept a string of comma separated MIME typ…
Browse files Browse the repository at this point in the history
…es (#1370)
  • Loading branch information
dan-amoroso authored and steve-chavez committed Aug 6, 2019
1 parent ee40e7e commit d575852
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- #1369, Change `raw-media-types` to accept a string of comma separated MIME types - @Dansvidania

## [6.0.1] - 2019-07-30

### Added
Expand Down
18 changes: 6 additions & 12 deletions src/PostgREST/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ readOptions = do
<*> pure False
<*> (fmap (fmap coerceText) <$> C.subassocs "app.settings" C.value)
<*> (maybe (Right [JSPKey "role"]) parseRoleClaimKey <$> optValue "role-claim-key")
<*> (maybe ["public"] splitExtraSearchPath <$> optValue "db-extra-search-path")
<*> (maybe ["public"] splitOnCommas <$> optValue "db-extra-search-path")
<*> ((\x y -> QualifiedIdentifier x <$> y) <$> dbSchema <*> optString "root-spec")
<*> (fmap encodeUtf8 <$> optionalListOfText "raw-media-types")
<*> (maybe [] (fmap encodeUtf8 . splitOnCommas) <$> optValue "raw-media-types")

parseJwtAudience :: C.Key -> C.Parser C.Config (Maybe StringOrURI)
parseJwtAudience k =
Expand All @@ -180,12 +180,6 @@ readOptions = do
(Just "") -> pure Nothing
aud' -> pure aud'

optionalListOfText :: C.Key -> C.Parser C.Config [Text]
optionalListOfText k =
C.optional k (C.list C.string) >>= \case
Nothing -> pure []
Just types -> pure types

reqString :: C.Key -> C.Parser C.Config Text
reqString k = C.required k C.string

Expand Down Expand Up @@ -219,9 +213,9 @@ readOptions = do
parseRoleClaimKey (C.String s) = pRoleClaimKey s
parseRoleClaimKey v = pRoleClaimKey $ show v

splitExtraSearchPath :: C.Value -> [Text]
splitExtraSearchPath (C.String s) = strip <$> splitOn "," s
splitExtraSearchPath _ = []
splitOnCommas :: C.Value -> [Text]
splitOnCommas (C.String s) = strip <$> splitOn "," s
splitOnCommas _ = []

opts = info (helper <*> pathParser) $
fullDesc
Expand Down Expand Up @@ -283,7 +277,7 @@ readOptions = do
|# root-spec = "stored_proc_name"
|
|## content types to produce raw output
|# raw-media-types=["image/png","image/jpg"]
|# raw-media-types="image/png, image/jpg"
|]

pathParser :: Parser FilePath
Expand Down

0 comments on commit d575852

Please sign in to comment.