ETOOBUSY 🚀 minimal blogging for the impatient
Sending 204 "No Content" from Mojolicious
204AND pass an empty
Every now and then I’m coding a web API and I need to send back an empty
response, which is HTTP status code
204 (also known as No Content).
This is how to do it properly in Mojolicious, the real-time web framework for Perl:
$c->render(status => 204, data => '');
It has tripped me so many times:
- about 90% of them I use(d)
- I keep (hopefully kept) to leave out the
datapart because it just seems right (if status is 204, why bother?).
I hope writing this will help me avoid the bug the next time!
Update: this suggestion from
preaction in the comments below is
shorter and maybe easier to remember:
I say maybe because I pretty much never use
rendered, so it’s likely
I’ll forget it 🙄
Comments? Octodon, Twitter, GitHub, Reddit, or drop me a line!