-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into SQSERVICES-428-lh-…
…group-convs
- Loading branch information
Showing
24 changed files
with
347 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Wire.API.ServantProto where | ||
|
||
import Data.List.NonEmpty (NonEmpty (..)) | ||
import Imports | ||
import Network.HTTP.Media ((//)) | ||
import Servant | ||
|
||
-- | Type to tell servant that it should unrender request body or render | ||
-- response body with Protobuf | ||
data Proto | ||
|
||
-- | We do not use 'Data.ProtocolBuffers.Decode' so we get a little freedom in | ||
-- defining separate data types which match one to one with the protobuf and the | ||
-- data types which we actually use in business logic. Eventually we should | ||
-- think of better ways of doing this, perhaps using mu-schema or proto-lens as | ||
-- it is fairly difficult to keep our custom data type, e.g. in | ||
-- Wire.API.Message.Proto in sync with the proto files. | ||
class FromProto a where | ||
fromProto :: LByteString -> Either String a | ||
|
||
instance Accept Proto where | ||
contentTypes _ = ("application" // "x-protobuf") :| [] | ||
|
||
instance FromProto a => MimeUnrender Proto a where | ||
mimeUnrender _ bs = fromProto bs |
Oops, something went wrong.