LukeMathWalker / wiremock-rs

HTTP mocking to test Rust applications.
Apache License 2.0
620 stars 70 forks source link

Add set_body_raw #5

Closed exul closed 4 years ago

exul commented 4 years ago

This method allows to set a body and the content type to pass any payload as Vec<u8>, without having to overwrite the content type by calling insert_header with Content-Type.

I'm not sure if mime should be passed as http_types::Mime or just as &str to have less boilerplate code in the test. Edit: I've updated the code to pass a &str, otherwise the user of the library needs the http_types crate as a dev dependency just to be able to pass http_types::Mime.

Closes https://github.com/LukeMathWalker/wiremock-rs/issues/3.

LukeMathWalker commented 4 years ago

Ideally we'd like to have TryInto<Mime> as argument, but right now Mime does not implement TryFrom for strings, so better to stick with &str for the type being. We can relax it later if http_types provides additional conversions.

LukeMathWalker commented 4 years ago

Thank you for the PR!