Skip to main content

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

NameDefaultTypeDescription
enabledtruebooleanEnable or disable the response-format service. Set to false to stop it.

Options

NameDefaultTypeDescription
defaultjsonstringThe default format used when the request path doesn't specify a format type. Must be json or csv.
formats-listA list of supported response format types. Include the format type if you need to use it in the path.

Example Scenarios

AcceptAPI URL Pathoptions.defaultoptions.formatsresponse format type
application/json;q=0.9/api/datajson["json","csv"]json
application/json;q=0.8, text/csv;q=0.9/api/datajson["json","csv"]csv
Not set/api/datajson["json","csv"]json
Not set/api/datajson["csv","json"]csv
Not set/api/datajsonNot setjson
application/json;q=0.9/api/data.csvjson["json","csv"]csv
application/json;q=0.9, text/csv;q=0.9/api/data.jsoncsv["csv"]Error
application/json;q=0.9, text/csv;q=0.9/api/dataNot setNot setjson