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

Expose accepts() methods in the Request #1

Closed
mcollina opened this issue Jul 22, 2017 · 2 comments
Closed

Expose accepts() methods in the Request #1

mcollina opened this issue Jul 22, 2017 · 2 comments
Assignees
Labels
semver-minor Issue or PR that should land as semver minor

Comments

@mcollina
Copy link
Member

I think having some more accessors in the Request  might be pretty handy, as an example:

fastify.post('/', function (req, reply) {
  switch(req.type(['json', 'html'])) {
    case 'json':
      reply.type('application/json').send({hello: 'world'})
      break
    case 'html':
      reply.type('text/html').send('<b>hello, world!</b>')
      break
    default:
      reply.send(Boom.notAcceptable('unacceptable'))
      break
  }
})
@allevo allevo added the semver-minor Issue or PR that should land as semver minor label Jul 22, 2017
@allevo
Copy link
Member

allevo commented Jul 22, 2017

Nice!

Should we cache the Accepts object for multiple queries on the sample Request instance?

@allevo allevo self-assigned this Jul 22, 2017
@mcollina
Copy link
Member Author

Yes. I would store it with a symbol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor Issue or PR that should land as semver minor
Projects
None yet
Development

No branches or pull requests

2 participants