babelouest / ulfius

Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
https://babelouest.github.io/ulfius
GNU Lesser General Public License v2.1
1.08k stars 182 forks source link

How to set http header content-type as application/json #201

Closed zhangsen1860 closed 3 years ago

zhangsen1860 commented 3 years ago

Hello, I need to send post request to other rest service, and the Content-Type application/json is required, so how to set the http header, and is the JANSSON required when compiling libulfius.so?

babelouest commented 3 years ago

Hello,

As stated in the install documentation, you need to use the flag -DWITH_JANSSON=off to disable Jansson support.

Also, to set the content-type header in the response, you can use ulfius_set_response_properties as explained in the API documentation

Happy hacking!