-
Notifications
You must be signed in to change notification settings - Fork 213
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
Ability to add custom headers to requests in integration framework #122
Conversation
76094c0
to
ad5d1d2
Compare
@@ -129,31 +133,34 @@ request' | |||
) | |||
=> (Method, Text) | |||
-- ^ HTTP method and request path | |||
-> Maybe RequestHeaders | |||
-- ^ Request headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to use a Map HeaderName Header
or [RequestHeaders]
here instead and perform a union with the base / default headers later: requestHeaders = baseHeaders <> extraHeaders
. This will allow overwriting the base headers when necessary and/or provide extra ones still fairly easily, or none using mempty
.
What do you think @piotr-iohk ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I follow. RequestHeaders
is just [Header]
(and Header
is (HeaderName, ByteString)
) so why use [ResuestHeaders]
?
Also how would it be possible to overwrite the baseHeaders
? (I understand that providing mempty
or []
(if I'll change to [Header]
) would be having just base (as a result of base <> mempty
), providing some extraHeaders
would add
base and extra but how to overwrite base then?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a Map
and doing the union between two maps, we'll the values associated to keys present in the second map overriding the one corresponding to keys present in the first map (if present).
So:
>>> let m1 = Map.fromList [("a", 1), ("b", 2)]
>>> let m2 = Map.fromList [("a", 14), ("c", 42)]
>>> m1 <> m2
Map.fromList [("a", 14), ("b", 2), ("c", 42)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Well, in fact it is:
Prelude> import qualified Data.Map as Map
Prelude Map> let m1 = Map.fromList [("a", 1), ("b", 2)]
Prelude Map> let m2 = Map.fromList [("a", 14), ("c", 42)]
Prelude Map> m1 <> m2
fromList [("a",1),("b",2),("c",42)]
, but that's ok as the arguments can be flipped :) :
... still it won't allow something like providing no headers at all...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... still it won't allow something like providing no headers at all...
True. Aaaaand, okay. You've convinced me ^^
ad5d1d2
to
8e43304
Compare
Merged into #128. |
Issue Number
#94
Overview
Comments
Relates to #56.