环境变量VCAP_SERVICES
中的值将是您需要解析的JSON字符串,它将为您提供一个描述所有绑定服务的对象,其中包括名称,标签和计划等数据。如果您的Google“vcap服务”或“云代工环境变量”的第一个结果是this doc,并且它有一个section on VCAP_SERVICES
。下面是他们提供的这是什么JSON对象看起来像(后解析)的例子:
{
"elephantsql": [
{
"name": "elephantsql-c6c60",
"label": "elephantsql",
"tags": [
"postgres",
"postgresql",
"relational"
],
"plan": "turtle",
"credentials": {
"uri": "postgres://seilbmbd:[email protected]:5432/seilbmbd"
}
}
],
"sendgrid": [
{
"name": "mysendgrid",
"label": "sendgrid",
"tags": [
"smtp"
],
"plan": "free",
"credentials": {
"hostname": "smtp.sendgrid.net",
"username": "QvsXMbJ3rK",
"password": "HCHMOYluTv"
}
}
]
}