Skip to content

Instantly share code, notes, and snippets.

@chrisumbel
Created March 17, 2016 10:07
Show Gist options
  • Select an option

  • Save chrisumbel/bec83a46ff58e95a7cbe to your computer and use it in GitHub Desktop.

Select an option

Save chrisumbel/bec83a46ff58e95a7cbe to your computer and use it in GitHub Desktop.
DOTNET VCAP Services Parser
// using Newtonsoft.Json.Linq;
private String VCAPServices() {
if (Environment.GetEnvironmentVariable("VCAP_SERVICES") == null)
{
return @" {
""user-provided"": [
{
""credentials"": {
""uri"": ""http://localhost:13471""
},
""label"": ""user-provided"",
""name"": ""umbel-beverage"",
""syslog_drain_url"": """",
""tags"": []
}
]
}
";
}
else {
return Environment.GetEnvironmentVariable("VCAP_SERVICES");
}
}
private string ServivceURL() {
JObject vcapServices = JObject.Parse(VCAPServices());
return vcapServices["user-provided"].First(
o => o["name"].ToString() == "umbel-beverage")["credentials"]["uri"].ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment