lipanski / mockito

HTTP mocking for Rust!
MIT License
683 stars 59 forks source link

`with_header_from_request` for mock server #207

Closed alex-kattathra-johnson closed 8 hours ago

alex-kattathra-johnson commented 1 day ago

The ability to respond with a specific header based on request.

lipanski commented 1 day ago

Not sure I understand what you mean - can you explain what you're missing? The library already provides a way to respond with a specific header (check the docs).

alex-kattathra-johnson commented 1 day ago

I want to respond with a Sec-WebSocket-Accept header based on the key that is sent in the request header.

lipanski commented 1 day ago

Got it, so you need to set the response header to a dynamic value, like in Mock::with_body_from_request. I think this library could acommodate something like Mock::with_header_from_request with a similar signature. PRs are welcome ;)

alex-kattathra-johnson commented 1 day ago

@lipanski: Got you a PR! 😁

lipanski commented 8 hours ago

@alex-kattathra-johnson Looks great, thanks.

Released as 1.6.1