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.79.1 spec/support/metadata_test_server.rb
pact_broker-2.79.0 spec/support/metadata_test_server.rb
pact_broker-2.78.1 spec/support/metadata_test_server.rb
pact_broker-2.78.0 spec/support/metadata_test_server.rb
pact_broker-2.77.0 spec/support/metadata_test_server.rb
pact_broker-2.76.2 spec/support/metadata_test_server.rb
pact_broker-2.76.1 spec/support/metadata_test_server.rb
pact_broker-2.76.0 spec/support/metadata_test_server.rb
pact_broker-2.75.0 spec/support/metadata_test_server.rb
pact_broker-2.74.1 spec/support/metadata_test_server.rb
pact_broker-2.74.0 spec/support/metadata_test_server.rb
pact_broker-2.73.0 spec/support/metadata_test_server.rb
pact_broker-2.72.0 spec/support/metadata_test_server.rb
pact_broker-2.71.0 spec/support/metadata_test_server.rb
pact_broker-2.70.0 spec/support/metadata_test_server.rb
pact_broker-2.69.0 spec/support/metadata_test_server.rb
pact_broker-2.68.1 spec/support/metadata_test_server.rb
pact_broker-2.68.0 spec/support/metadata_test_server.rb
pact_broker-2.67.0 spec/support/metadata_test_server.rb
pact_broker-2.66.0 spec/support/metadata_test_server.rb