Specifiying compression for one endpoint/group rather than whole application

Viewed 138

My question is probably more related to the configuration.

Let's assume that I have an application with three endpoints:

package com.akamai.botf.tests.e2e.controllers

import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping('/')
class AppController {
  
  @GetMapping('plain')
  String plain() {
    "no compression"
  }

  @GetMapping("gzip")
  String gzip() {
    "gzipp"
  }

  @GetMapping("brotli")
  String brotli() {
    "brotli"
  }

}

How can I apply gzip compression to just one of those three endpoints (gzip). AFAIK settings.yml gives me the ability to launch compression:

server:
    compression:
        enabled: true
        excluded-user-agents: 
        mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript 
        min-response-size: 2048

But that applies to the whole application rather than specific class/endpoints.

0 Answers
Related