feat: add WithBody(req => dostuff) style callback (#102)

This commit is contained in:
Alastair Crabtree
2018-03-03 08:38:03 +00:00
committed by Stef Heyenrath
parent 2b8a58c68c
commit 3f2c139f90
3 changed files with 39 additions and 0 deletions

View File

@@ -167,6 +167,13 @@ namespace WireMock.ResponseBuilders
return this;
}
/// <inheritdoc cref="IBodyResponseBuilder.WithBody(Func{RequestMessage, string}, string, Encoding)"/>
public IResponseBuilder WithBody(Func<RequestMessage, string> bodyFactory, string destination = BodyDestinationFormat.SameAsSource,
Encoding encoding = null)
{
return WithCallback(req => new ResponseMessage {Body = bodyFactory(req)});
}
/// <inheritdoc cref="IBodyResponseBuilder.WithBody(byte[], string, Encoding)"/>
public IResponseBuilder WithBody(byte[] body, string destination, Encoding encoding = null)
{