Response Format
The Response Format plugin allows you to configure the supported API response formats and set the preferred format based on the HTTP Header - Accept. You can customize the settings using the project configuration file (vulcan.yaml by default) to meet your specific needs.
Usage
vulcan.yaml
response-format:
  enabled: true
  options:
    default: json
    formats:
      - json
      - csv
Settings
| Name | Default | Type | Description | 
|---|---|---|---|
| enabled | true | boolean | Enable or disable the response-format service. Set to falseto stop it. | 
Options
| Name | Default | Type | Description | 
|---|---|---|---|
| default | json | string | The default format used when the request path doesn't specify a format type. Must be jsonorcsv. | 
| formats | - | list | A list of supported response format types. Include the format type if you need to use it in the path. | 
Example Scenarios
| Accept | API URL Path | options.default | options.formats | response format type | 
|---|---|---|---|---|
| application/json;q=0.9 | /api/data | json | ["json","csv"] | json | 
| application/json;q=0.8, text/csv;q=0.9 | /api/data | json | ["json","csv"] | csv | 
| Not set | /api/data | json | ["json","csv"] | json | 
| Not set | /api/data | json | ["csv","json"] | csv | 
| Not set | /api/data | json | Not set | json | 
| application/json;q=0.9 | /api/data.csv | json | ["json","csv"] | csv | 
| application/json;q=0.9, text/csv;q=0.9 | /api/data.json | csv | ["csv"] | Error | 
| application/json;q=0.9, text/csv;q=0.9 | /api/data | Not set | Not set | json |