Sha256: e70e67a5f6e6766fd26a093162e0d590e9382e3e9610eb8eb4ef3c87012b90e4

Contents?: true

Size: 1000 Bytes

Versions: 117

Compression:

Stored size: 1000 Bytes

Contents

#!/usr/bin/env ruby
# Copyright (c) 2009-2011 VMware, Inc.
$:.unshift(File.dirname(__FILE__) + '/lib')

require 'rubygems'
require 'bundler/setup'

require 'caldecott'
require 'sinatra'
require 'json'
require 'eventmachine'

port = ENV['PORT']
port ||= 8081

# add vcap specific stuff to Caldecott
class VcapHttpTunnel < Caldecott::Server::HttpTunnel
  get '/info' do
    { "version" => '0.0.4' }.to_json
  end

  def self.get_tunnels
    super
  end

  get '/services' do
    services_env = ENV['VCAP_SERVICES']
    return "no services env" if services_env.nil? or services_env.empty?
    services_env
  end

  get '/services/:service' do |service_name|
    services_env = ENV['VCAP_SERVICES']
    not_found if services_env.nil?

    services = JSON.parse(services_env).values.flatten(1)
    service = services.find { |s| s["name"] == service_name }
    not_found if service.nil?
    service["credentials"].to_json
  end
end

VcapHttpTunnel.run!(:port => port, :auth_token => ENV["CALDECOTT_AUTH"])

Version data entries

117 entries across 117 versions & 4 rubygems

Version Path
cf-4.2.1.rc3 lib/tunnel/helper-app/server.rb
cf-4.2.1.rc2 lib/tunnel/helper-app/server.rb
cf-4.2.1.rc1 lib/tunnel/helper-app/server.rb
cf-4.2.0 lib/tunnel/helper-app/server.rb
cf-4.1.5.rc7 lib/tunnel/helper-app/server.rb
cf-4.1.5.rc6 lib/tunnel/helper-app/server.rb
cf-4.1.5.rc5 lib/tunnel/helper-app/server.rb
cf-4.1.5.rc4 lib/tunnel/helper-app/server.rb
cf-4.1.5.rc3 lib/tunnel/helper-app/server.rb
cf-4.1.5.rc2 lib/tunnel/helper-app/server.rb
cf-4.1.5.rc1 lib/tunnel/helper-app/server.rb
cf-4.1.4 lib/tunnel/helper-app/server.rb
cf-4.1.4.rc2 lib/tunnel/helper-app/server.rb
cf-4.1.4.rc1 lib/tunnel/helper-app/server.rb
cf-4.1.3 lib/tunnel/helper-app/server.rb
cf-4.1.2.rc2 lib/tunnel/helper-app/server.rb
cf-4.1.2.rc1 lib/tunnel/helper-app/server.rb
cf-4.1.1 lib/tunnel/helper-app/server.rb
cf-4.1.0rc2 lib/tunnel/helper-app/server.rb
cf-4.1.0rc1 lib/tunnel/helper-app/server.rb