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

How to compress the output of an ejs template rendered reply without set the global flag #89

Closed
red1 opened this issue Nov 5, 2019 · 8 comments
Labels

Comments

@red1
Copy link

red1 commented Nov 5, 2019

Hello
i'm doing something like that :
reply.view('/src/templates/hello.ejs', { hello: 'world' })
I'd like to compress the output of my ejs template, .compress will not work directly and I don't want to activate the global flag
Do you know how can I do that ? can we enrich the component with a compressOnSend method to accept to be chained and activate the onsend hook ?
reply.view('/src/templates/hello.ejs', { hello: 'world' }).compressOnSend()
Thanks

@mcollina
Copy link
Member

mcollina commented Nov 5, 2019

I think this is better solved in the fastify-compress module, adding support for compressing a single route. This is already possible given the internals of the framework, we are only missing support in fastify-compress.

@red1
Copy link
Author

red1 commented Nov 5, 2019

It would be great yes please!

@red1
Copy link
Author

red1 commented Nov 10, 2019

Hello @mcollina
Do you know if this support will be added ?

@mcollina
Copy link
Member

If somebody would like to work on it, yes!

@Eomm
Copy link
Member

Eomm commented Nov 10, 2019

You could try to implement it 💪

this plugin: https://github.com/fastify/fastify-rate-limit has this kind of feature: global and/or per-route usage, you may get some inspiration from it!

@marc-fisher-q2e
Copy link

Is there a way to hook into onSend per route? The last per route option in the lifecycle right now is preSerialization so any thoughts on how this could work?

@Eomm
Copy link
Member

Eomm commented Nov 29, 2019

Is there a way to hook into onSend per route?

No, right now there is not this option, but it should easy to add here:
https://github.com/fastify/fastify/blob/master/lib/route.js#L9

so any thoughts on how this could work?

Good point, we should add to fastify that parameter, then this issue can be implemented

@stale
Copy link

stale bot commented Oct 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 21, 2020
@stale stale bot closed this as completed Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants