Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Does Play Framework add Content-Type headers automatically?
- import javax.inject.Inject
- import play.api.libs.json.Json
- import play.api.mvc._
- class TestController @Inject() (
- cc: ControllerComponents,
- ) extends AbstractController(cc) {
- // add to routes: GET /test/json controllers.TestController.simpleJson
- def simpleJson = Action {
- Ok(Json.obj("key" -> 5, "value" -> List(1, 2, 3)))
- }
- }
- // Call: http://localhost:9000/test/json
- // Output: {"key":5,"value":[1,2,3]}
- // Headers:
- Content-Length 25
- Content-Security-Policy default-src 'self'
- Content-Type application/json
- Date Sun, 19 Aug 2018 19:17:51 GMT
- Referrer-Policy origin-when-cross-origin, strict-origin-when-cross-origin
- X-Content-Type-Options nosniff
- X-ExampleFilter foo
- X-Frame-Options DENY
- X-Permitted-Cross-Domain-Policies master-only
- X-XSS-Protection 1; mode=block
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement