-
Hi everyone I am building some more complex application which helps create backend websites easier without sacrificing performance (all notes and credits about uWebSockets.js will be on app). But there i have to ask question about Separate corkapp.get('/cork', async (res) => {
res.cork(() => {
res.writeStatus('301 Moved Permanently');
});
res.cork(() => {
res.writeHeader('Content-Type', 'application/text');
});
res.cork(() => {
res.end('success');
});
}); Single corkapp.get('/cork', async (res) => {
res.cork(() => {
res.writeStatus('301 Moved Permanently');
res.writeHeader('Content-Type', 'application/text');
res.end('success');
});
}); I know Single cork will be faster and more efficiently but it is possible to use Separate cork way and it is not bad / bad practice? If i use Separate cork way, uWebSockets.js will merge those into single cork automatically or not? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Used another approach and it's more efficient in terms of response but performance may be not the fastest Batch corkapp.get('/cork', async (res) => {
const corks = [];
corks.push(() => {
res.writeStatus('301 Moved Permanently');
});
corks.push(() => {
res.writeHeader('Content-Type', 'application/text');
});
corks.push(() => {
res.end('success');
});
return res.cork(() => {
for (const cork of corks) {
cork();
}
});
}); |
Beta Was this translation helpful? Give feedback.
-
There is nothing in the license encouraging or requiring you to give any kind of credit. In fact, the license only makes requirements on the opposite. Separate cork: horrible, just horrible. Can't make it any worse than that. |
Beta Was this translation helpful? Give feedback.
Used another approach and it's more efficient in terms of response but performance may be not the fastest
Batch cork