通过接口自助实现压缩响应功能
| 参数名称 | 描述 |
|---|---|
domain-nameString | 需要查询配置的域名或域名id |
| 参数名称 | 描述 |
|---|---|
*compression-settingsObject | 压缩响应功能配置 1.需要设置压缩响应配置时,此项必填 2.为空<compression-settings/>时清空压缩响应配置 |
compression-enabledString | 开启压缩响应功能:允许值为true和false |
br-typesString | 是否使用br压缩:允许值为true和false |
specify-url-patternString | 指定URI |
custom-file-typesList | 自定义文件类型:在指定文件类型外根据自身需求,填写适当的可识别文件类型。可以搭配uri-file-types使用。如果uri-file-types也有配置,实际生效的文件类型是两个入参的总和 |
file-typesList | MIME类型配置需要压缩的文件类型,默认只对'text'文件类型压缩,配置为*时压缩任意文件类型 |
ignore-letter-caseString | 是否忽略大小写:允许值为true和false |
path-patternString | url匹配模式,支持正则,如果是全部匹配,入参可以配置为:.* |
custom-patternString | 指定常用类型:允许值为homepage和all |
uri-file-typesList | 文件类型:指定需要缓存的文件类型。 文件类型包括:gif png bmp jpeg jpg html htm shtml mp3 wma flv mp4 wmv zip exe rar css txt ico js swf 如果需要全部类型,则直接传all。多个以分号隔开,all和具体文件类型不能同时配置。 |
directoryString | 目录 |
file-type-othersList | 指定文件类型开启压缩响应的另一种方式,为空可清空配置 |
| 参数名称 | 描述 |
|---|---|
codeString | 错误代码,当HTTPStatus不为202时出现,表示当前请求调用的错误类型 |
httpStatusInteger | httpstatus=202; 表示成功调用新增域名接口,可使用header中的x-cnc-request-id查看当前新增域名的部署情况 |
x-cnc-request-idString | 唯一标示的id,用于查询每次请求的任务 (适用全部接口) |
messageString | 响应信息,成功时为success |
| 错误代码(code) | 描述(message) | HTTP状态码 | 语义 |
|---|---|---|---|
| NoSuchDomain | The specified domain does not exist.\n\n | 404 | 域名资源项不存在\n\n |
| CustomerNoOwnDomain | customer not own domain name[www.example.com].\n\n | 400 | 域名不属于该客户\n\n |
| ConfigError | The config {0} does not access.\n\n | 400 | 某个配置无法访问\n\n |
| InvalidParameter | example: 1. No domain was specified.2.The {0} is invalid.\n\n | 400 | 指定入参格式错误\n |
#!/bin/bash
username="example_username"
apiKey="example_apiKey"
date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"`
password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64`
curl -i --url "https://api.cdnetworks.com/api/config/compresssetting/123344" \
-X "PUT" \
-u "$username:$password" \
-H "Date: $date" \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-d '
{
"compression-settings":{
"compression-enabled":"true",
"path-pattern":"*",
"ignore-letter-case":"true",
"file-types":[ "image/jpeg", "application/" ],
"uri-file-types":[ "mp3", "zip" ],
"custom-file-types":[ "json", "wasm" ],
"custom-pattern":"homepage",
"directory":"/directory/",
"specify-url-pattern":"/abc/.*",
"br-types":"true"
}
}'HTTP/1.1 202 Accepted
Server: openresty/1.11.2.2
Date: Mon, 27 May 2019 07:15:49 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 31
Connection: keep-alive
App-Name: service_confApi
x-cnc-request-id: 90d3b33c-3931-4436
{
"message":"success",
"code":""
}