public Task MutateOutgoing(MutateOutgoingTransportMessageContext context) { if (context.TryGetIncomingMessage(out var incomingMessage)) { // do something with the incoming message } if (context.TryGetIncomingHeaders(out var incomingHeaders)) { // do something with the incoming headers } // the outgoing message var outgoingMessage = context.OutgoingMessage; // the bytes containing the serialized outgoing messages. var bytes = context.OutgoingBody; // optionally replace the Body. // this can be done using any information from the context context.OutgoingBody = ServiceThatChangesBody.Mutate(context.OutgoingMessage); // the outgoing headers var headers = context.OutgoingHeaders; // optional manipulate headers // add a header headers.Add("MyHeaderKey1", "MyHeaderValue"); // remove a header headers.Remove("MyHeaderKey2"); return(Task.CompletedTask); }
public Task MutateIncoming(MutateIncomingTransportMessageContext context) { // the bytes of the incoming messages. var bytes = context.Body; // optionally replace the Body context.Body = ServiceThatChangesBody.Mutate(context.Body); // the incoming headers var headers = context.Headers; // optional manipulate headers // add a header headers.Add("MyHeaderKey1", "MyHeaderValue"); // remove a header headers.Remove("MyHeaderKey2"); return(Task.CompletedTask); }
public Task MutateOutgoing(MutateOutgoingTransportMessageContext context) { object incomingMessage; if (context.TryGetIncomingMessage(out incomingMessage)) { // do something with the incoming message } IReadOnlyDictionary <string, string> incomingHeaders; if (context.TryGetIncomingHeaders(out incomingHeaders)) { // do something with the incoming headers } // the outgoing message object outgoingMessage = context.OutgoingMessage; // the bytes containing the serialized outgoing messages. byte[] bytes = context.OutgoingBody; // optionally replace the Body. // this can be done using any information from the context context.OutgoingBody = ServiceThatChangesBody.Mutate(context.OutgoingMessage); // the outgoing headers IDictionary <string, string> headers = context.OutgoingHeaders; // optional manipulate headers // add a header headers.Add("MyHeaderKey1", "MyHeaderValue"); // remove a header headers.Remove("MyHeaderKey2"); return(Task.FromResult(0)); }
public Task MutateIncoming(MutateIncomingTransportMessageContext context) { // the bytes containing the incoming messages. byte[] bytes = context.Body; // optionally replace the Body context.Body = ServiceThatChangesBody.Mutate(context.Body); // the incoming headers IDictionary <string, string> headers = context.Headers; // optional manipulate headers // add a header headers.Add("MyHeaderKey1", "MyHeaderValue"); // remove a header headers.Remove("MyHeaderKey2"); return(Task.FromResult(0)); }