aardio 文档

aardio 范例: 资源名编码

//资源名编码
import console;
import web.rest.jsonLiteClient;
import crypt.bin;

var http = web.rest.jsonLiteClient();

//自定义资源名内中文字符改为 Base64 编码
http.encodeKey = lambda(v) string.replace(v,":",crypt.bin.encodeUrlBase64); 

//创建 API
var countApi = http.api("https://api.countapi.xyz/hit{/domain}{/key}")

//调用 API
var data = countApi["example.com"]["password"].get();
console.log( data[["value"]] ); 

//这样写也可以
var data = countApi[{
    domain = "example.com";
    key = "password" 
}].get(); 

//省略一个参数也可以
var data = countApi["测试一下-aardio范例"].get(); 
console.log( data[["value"]] ); 

console.pause();

Markdown 格式