API Data Compression
What’s the problem you're trying to solve
Support gzip compression to compress the data result ( e.g: JSON, CSV ).
Describe the solution you’d like
Support three parameters - always, enable, disable for setting compression gzip in each API schema to control compression by Accept-Encoding or ending word of API URL
# schema.yaml
gzip: enable
The enable mode ( control by request )
The enable means do the Gzip compression feature according to you pass Accept-Encoding: gzip in the header, or indicating the .gz in the URL ending or not, like below:
- Do Gzip compression JSON result -
/xxxx.json.gz, - Do Gzip compression from JSON result -
/xxxx.json.gz, - Do Gzip compression from CSV result -
/xxxx.csv.gz
The priority is detecting the URL ending word .gz first, then detecting the HTTP header Accept-Encoding: gzip second, below is samples:
- If you don't pass
Accept-Encoding: gzip, but you add the.gzon the URL ending word, then we will do the Gzip compression. - If you pass
Accept-Encoding: gzip, but you do not add the.gzon the URL ending word, then we will do the Gzip compression too.
The always mode
The always means always do the Gzip compression, whether you specify the URL ending word or give it by HTTP header Accept-Encoding: gzip.
The disable mode
The disable means never do the Gzip compression feature, so even if you pass .gz in the URL ending word or Accept-Encoding: gzip in the header, it still does not do the compression.