dom96 / httpbeast

A highly performant, multi-threaded HTTP 1.1 server written in Nim.
MIT License
450 stars 53 forks source link

Make using custom headers easier/nicer #94

Open victormihalache opened 10 months ago

victormihalache commented 10 months ago

With this commit you can go from having to write:

req.send(Http200, getTime().format("yyyy-MM-dd"), "Access-Control-Allow-Origin: *")

to writing:

req.send(getTime().format("yyyy-MM-dd"), "Access-Control-Allow-Origin: *")

It's a small change, but given we already have something similar for sending a body with a custom code—very handy for when a custom response code is needed—to me it only makes sense we have one for custom headers, something that gets set far more often.

Sorry if this may be out of scope, I just found it a personal annoyance having to write Http200, every time just because I needed a custom header.

Lastly, I do not know wether or not this should have the {. inline .} pragma or not.