connectrpc / connect-swift

The Swift implementation of Connect: Protobuf RPC that works.
https://connectrpc.com/docs/swift/getting-started
Apache License 2.0
98 stars 20 forks source link

Combine headers + trailers into `ConnectError.metadata` #239

Closed rebello95 closed 9 months ago

rebello95 commented 9 months ago

As described by @jhump:

Currently, users may need to check both headers and trailers when looking for metadata in an error response for an operation with a unary reply (unary and client-stream RPCs). The reason they may have to look in two places is because where the metadata shows up isn't straight-forward - it depends on if the protocol being used and, if gRPC or gRPC-Web, whether the server used a trailers-only response or not. In a trailers-only response, all metadata would show up in the same bag of metadata (which are technically HTTP response headers, but may be classified as "trailers" since they include the status and there will be no subsequent HTTP response trailers in the reply).

This PR updates ConnectError's initialization to combine both headers + trailers into its metadata so that it's easier for consumers to query for the keys they need. This also matches connect-go and connect-es.

rebello95 commented 9 months ago

@eseay would you mind taking a look at this as well? 🙏🏽