soveran / cuba

Rum based microframework for web development.

Home Page:http://cuba.is

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show small example on how to render content-type, headers, etc

mulderp opened this issue · comments

Hello,

I was just playing with Cuba, and I would need to render JSON in the response for simulating API calls. However, I can't quickly see in the docs, how you responds with non-HTML.

Any pointers?

Thanks!

You can do:

res.headers["Content-Type"] = "application/json; charset=utf-8"
res.write(foo.to_json)

nice! thanks for this snippet.