I'm learning Scalatra and am wondering how I can make the default Content-Type of my responses application/json
. The current default appears to be text/html
. Neat, but not really useful to my application.
The current default is text/html
.
$ curl -i -X GET 'http://localhost:8080/v1/example'
HTTP/1.1 200 OK
Date: Fri, 19 Apr 2019 07:21:21 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 23
Server: Jetty(9.4.8.v20171121)
HelloWorld(hello,world)
I can get application-json
explicitly through the Accepted: application/json
header.
$ curl -i -X GET 'http://localhost:8080/v1/example' -H 'Accept: application/json'
HTTP/1.1 200 OK
Date: Fri, 19 Apr 2019 07:22:09 GMT
Content-Type: application/json;charset=utf-8
Transfer-Encoding: chunked
Server: Jetty(9.4.8.v20171121)
{"hello":"hello","world":"world"}
How do I set the default to be application/json
.