-
Notifications
You must be signed in to change notification settings - Fork 9
Add servant 0.19 support to servant-util #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0a6a41d
5ccce73
d361806
f7b494b
862fec2
3b29e86
814fb12
69c3a3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| packages: | ||
| ./servant-util | ||
| ./servant-util-beam-pg |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| Unreleased | ||
| ===== | ||
|
|
||
| * Added support for building the project with `servant` version >= 0.19. | ||
|
|
||
| 0.3 | ||
| === | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| {-# LANGUAGE CPP #-} | ||
| {-# LANGUAGE DeriveFunctor #-} | ||
| {-# LANGUAGE TypeInType #-} | ||
|
|
||
|
|
@@ -20,8 +21,10 @@ module Servant.Util.Combinators.Filtering.Base | |
| , AreAutoFilters (..) | ||
| , FilteringValueParser (..) | ||
| , OpsDescriptions | ||
| , EncodedQueryParam | ||
| , parseFilteringValueAsIs | ||
| , unsupportedFilteringValue | ||
| , encodeQueryParam | ||
| , autoFiltersParsers | ||
|
|
||
| , FilteringParamTypesOf | ||
|
|
@@ -37,6 +40,10 @@ import Fmt (Buildable (..), Builder) | |
| import GHC.Exts (IsList) | ||
| import Servant (FromHttpApiData (..), ToHttpApiData (..)) | ||
| import Servant.API (NoContent) | ||
| #if MIN_VERSION_servant(0,19,0) | ||
| import Data.ByteString.Builder (toLazyByteString) | ||
| import qualified Data.ByteString.Lazy as BL | ||
| #endif | ||
|
|
||
| import Servant.Util.Common | ||
|
|
||
|
|
@@ -90,6 +97,18 @@ unsupportedFilteringValue errMsg = FilteringValueParser (\_ -> Left errMsg) | |
| -- This is not a 'Map' to prevent developer-defined entries order. | ||
| type OpsDescriptions = [(Text, Text)] | ||
|
|
||
| -- | Specify the encoding type and function for query parameters. | ||
| -- It's required due to this https://github.com/haskell-servant/servant/pull/1432 | ||
| #if MIN_VERSION_servant(0,19,0) | ||
| type EncodedQueryParam = ByteString | ||
| encodeQueryParam :: ToHttpApiData a => a -> EncodedQueryParam | ||
| encodeQueryParam = BL.toStrict . toLazyByteString . toEncodedUrlPiece | ||
| #else | ||
| type EncodedQueryParam = Text | ||
| encodeQueryParam :: ToHttpApiData a => a -> EncodedQueryParam | ||
| encodeQueryParam = toQueryParam | ||
| #endif | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems really awkward. How bad would it be to bump the dependency version?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not like this solution too. If supporting servant 0.18 is not required, let's remove it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you were thinking something like this marinelli@a0dbeeb?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Martoon-00 what do you think about it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I apologize for the late reply 🙏 🙏 I don't like such tricks with CPP pragmas too, but in this case its scope is sufficiently limited and it seems like the least evil to me. Let's go with the current solution to leave others some time if they need a recent feature of I also asked our OPS team to make CI run both the old and new versions of @marinelli You are also very welcome to start using haskell-servant/servant#1549 here as soon as it appears in a release. Just leave a note in the changelog that we do not support Thanks a lot for your work!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure anymore that re-exporting |
||
|
|
||
| -- | How auto filters appear in logging. | ||
| class BuildableAutoFilter (filter :: Type -> Type) where | ||
| buildAutoFilter | ||
|
|
@@ -112,7 +131,7 @@ class (Typeable filter, BuildableAutoFilter filter) => | |
| -- | Encode a filter to query parameter value. | ||
| autoFilterEncode | ||
| :: ToHttpApiData a | ||
| => filter a -> (Text, Text) | ||
| => filter a -> (Text, EncodedQueryParam) | ||
|
|
||
| mapAutoFilterValue | ||
| :: (a -> b) -> filter a -> filter b | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.