Sha256: d3a990f29e42f9bf19fb3525b6056843b65a0b2c3b46f8a76e030a183ed3dd9a

Contents?: true

Size: 759 Bytes

Versions: 66

Compression:

Stored size: 759 Bytes

Contents

if __FILE__ == $0
  require 'json'
  require 'base64'
  STDOUT.sync = true

  trap(:INT) do
    @server.shutdown
    exit
  end

  def webrick_opts port
    {
      Port: port,
      Host: "0.0.0.0",
      AccessLog: [],
    }
  end

  app = ->(env) do
    env['rack.input'].rewind
    body_hash = JSON.parse(env['rack.input'].read)
    metadata = body_hash["pactUrl"].split("/").last

    metadata_string = Base64.strict_decode64(metadata)
    metadata = Rack::Utils.parse_nested_query(metadata_string)
    # hash = JSON.parse(json)
    [200, {}, [metadata.to_json]]

  end

  require 'webrick'
  require 'rack'
  require 'rack/handler/webrick'

  opts = webrick_opts(4445)

  Rack::Handler::WEBrick.run(app, opts) do |server|
    @server = server
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
pact_broker-2.65.0 spec/support/metadata_test_server.rb
pact_broker-2.64.0 spec/support/metadata_test_server.rb
pact_broker-2.63.0 spec/support/metadata_test_server.rb
pact_broker-2.62.0 spec/support/metadata_test_server.rb
pact_broker-2.61.0 spec/support/metadata_test_server.rb
pact_broker-2.60.1 spec/support/metadata_test_server.rb
pact_broker-2.60.0 spec/support/metadata_test_server.rb
pact_broker-2.59.2 spec/support/metadata_test_server.rb
pact_broker-2.59.1 spec/support/metadata_test_server.rb
pact_broker-2.59.0 spec/support/metadata_test_server.rb
pact_broker-2.58.3 spec/support/metadata_test_server.rb
pact_broker-2.58.2 spec/support/metadata_test_server.rb
pact_broker-2.58.0 spec/support/metadata_test_server.rb
pact_broker-2.57.0 spec/support/metadata_test_server.rb
pact_broker-2.56.1 spec/support/metadata_test_server.rb
pact_broker-2.56.0 spec/support/metadata_test_server.rb
pact_broker-2.55.0 spec/support/metadata_test_server.rb
pact_broker-2.54.0 spec/support/metadata_test_server.rb
pact_broker-2.53.0 spec/support/metadata_test_server.rb
pact_broker-2.52.2 spec/support/metadata_test_server.rb