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.36.1 spec/support/metadata_test_server.rb
pact_broker-2.36.0 spec/support/metadata_test_server.rb
pact_broker-2.35.0 spec/support/metadata_test_server.rb
pact_broker-2.34.0 spec/support/metadata_test_server.rb
pact_broker-2.33.0 spec/support/metadata_test_server.rb
pact_broker-2.32.0 spec/support/metadata_test_server.rb