Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: response options as function #441

Open
AndersDJohnson opened this issue Sep 26, 2019 · 0 comments
Open

feat: response options as function #441

AndersDJohnson opened this issue Sep 26, 2019 · 0 comments
Assignees

Comments

@AndersDJohnson
Copy link
Member

AndersDJohnson commented Sep 26, 2019

We may be able to support providing a function to generate entire response options - similar to how we support functions for some response option keys like json, text, latency, status, etc. This would enable a few more complex behaviors, e.g., allow us to conditionally return different content types:

mockyeah.get('/hi', (req, res) => {
  if (req.query.format === 'text') {
    return {
      text: 'bar'
    }
  } else {
    return {
      json: { bar: true }
    }
  }
})

Relates to #530.

Not sure how we would still support the name property on response options without always calling the function - especially on misses where we wouldn't normally call this. Maybe rely on the function .name property?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant