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

support streams #23

Closed
mcollina opened this issue Nov 3, 2016 · 4 comments
Closed

support streams #23

mcollina opened this issue Nov 3, 2016 · 4 comments

Comments

@mcollina
Copy link
Member

mcollina commented Nov 3, 2016

We should be able to call reply(null, stream).

@marcbachmann
Copy link

Oh, nice. I just landed on this issue by accident. I also need something like that in my setup.
I guess fastify responds with Content-Type: application/json by default, right?
So would you only support utf8 encoded streams and the stream is responsible to support proper json?

Or would you allow a custom content type by passing it somewhere?
And then we can also support line delimited json.

e.g.

fastify.get('/documents', function (opts, reply) {
  // returns a stream in object mode
  var stream = database.select('*').from('documents').toStream()

  // Set content type on stream
  stream['Content-Type'] = 'application/x-ndjson'
  reply(null, stream)
  // or
  reply(null, stream, {'Content-Type': 'application/x-ndjson'})
})

@mcollina
Copy link
Member Author

mcollina commented Dec 1, 2016

I think we should do something with reply, rather than setting properties on the stream object.

@delvedor
Copy link
Member

delvedor commented Dec 1, 2016

I'm working on stream support at the moment, in the next days will land a pr :)
https://github.com/mcollina/fastify/tree/stream-support

@delvedor delvedor mentioned this issue Dec 1, 2016
4 tasks
@delvedor
Copy link
Member

delvedor commented Jan 4, 2017

Stream support added in #27.

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

No branches or pull requests

3 participants