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

Consider adding support for returning more than just body from responseBodyBuilder #4

Closed
samandmoore opened this issue Nov 20, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@samandmoore
Copy link
Member

samandmoore commented Nov 20, 2021

i'm musing about something like this

// return this, no processing
return CharlatanResponse.raw(
  body: '{"id": 12}', // already a string
  headers: {'content-type': 'application/json'},
  statusCode: 200,
);

// return this but process the body
return CharlatanResponse(
  // still a map to be converted automatically based on the incoming accept header
  // or defaulting to json
  {'id': 12},
  statusCode: 200,
);

// current behavior would still work
return {'id': 12}; 

the reason i'm curious about this approach is that it would be nice to have a way to dynamically decide on the status code in addition to the response body. e.g. sometimes you might wanna do a 422 and not a 200.

@samandmoore samandmoore added the enhancement New feature or request label Nov 20, 2021
@samandmoore
Copy link
Member Author

resolved in #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant