I'm working on the REST APIs(Spring boot), dealing with large size responses(around 15mb). I want to reduce the response size and by compressing it using GZIP.
These are the request headers(through postman)-
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
My application.properties
server.compression.enabled=true
server.compression.mime-types=application/json,application/geo+json
server.compression.gzip.level=1
Following is my controller code to return large size response by compressing it using GZIP.
@GetMapping("/get")
@Operation(operationId="OP_ID", summary = "API_SUMMARY", description = "ENDOPINT_DESCRIPTION")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Response on success", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = FeatureCollection.class)) }),
@ApiResponse(responseCode = "4XX/5XX", description = "Response on failure", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorResponseObject.class))}) })
public ResponseEntity<FeatureCollection> getCycleData(String cycleId, String country) throws Exception {
//Code to fetch 'featureCollection'
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add(HttpHeaders.CONTENT_ENCODING, "gzip"); // Enable Gzip compression
return new ResponseEntity<FeatureCollection>(featureCollection, headers, HttpStatus.OK);
}
I'm seeing this error in postman-
Error: incorrect header check