Bogdan Barliga
06/14/2024, 8:57 AMrequest.metadata
field.
This has worked fine for a RUST consumer, but I am struggling to replicate this using the FFI.
Will give more details in thread.Bogdan Barliga
06/14/2024, 8:58 AMpath
entry in the request.metadata
(required for establishing the initial connection):
...
"request": {
"contents": {
...
"metadata": {
"contentType": "application/json",
"path": "/jsonrpc"
}
...
The consumer achieves this by making use of the contents_from
, along the lines of:
let mock_server = pact_builder
.synchronous_message_interaction("sync message example", |mut i| async move {
i.contents_from(json!({
"pact:content-type": "application/json",
"request": {
"query": "matching(equalTo, 'getTheData')"
},
"requestMetadata": {
"path": "/jsonrpc"
},
},
"response": [{
"data": "matching(equalTo, 'The data')"
}]
}))
...
For the FFI consumer I am using pactffi_new_sync_message_interaction
and the pactffi_
methods that work with InteractionHandle
.
Ideally I would like to achieve the same thing using the FFI, but I could not identify an API that would allow this.
Can someone advise if it is possible to achieve this using the current FFI API? Or is this something that is missing and needs to be added?Joshua Ellis
06/14/2024, 9:07 AMwith_metadata
FFI for the InteractionHandle
in order to set additional metadata for either the request or response. Is that what you're looking for?
As it has only just been merged recently, there hasn't been a release yet, but you should be able to try it out by building the FFI library from dev if you want 🙂Bogdan Barliga
06/14/2024, 11:04 AMJoshua Ellis
06/14/2024, 11:06 AM