dsl/pact.go
func (p *Pact) VerifyProviderRaw(request types.VerifyRequest) (types.ProviderVerifierResponse, error) {
	p.Setup(false)
	var res types.ProviderVerifierResponse

	u, err := url.Parse(request.ProviderBaseURL)

	if err != nil {
		return res, err
	}

	m := []proxy.Middleware{}

	if request.BeforeEach != nil {
		m = append(m, BeforeEachMiddleware(request.BeforeEach))
	}

	if request.AfterEach != nil {
		m = append(m, AfterEachMiddleware(request.AfterEach))
	}

	if len(request.StateHandlers) > 0 {
		m = append(m, stateHandlerMiddleware(request.StateHandlers))
	}

	if request.RequestFilter != nil {
		m = append(m, request.RequestFilter)
	}

	// Configure HTTP Verification Proxy
	opts := proxy.Options{
		TargetAddress: fmt.Sprintf("%s:%s", u.Hostname(), u.Port()),
		TargetScheme:  u.Scheme,
		Middleware:    m,
	}

	// Starts the message wrapper API with hooks back to the state handlers
	// This maps the 'description' field of a message pact, to a function handler
	// that will implement the message producer. This function must return an object and optionally
	// and error. The object will be marshalled to JSON for comparison.
	port, err := proxy.HTTPReverseProxy(opts)

	// Backwards compatibility, setup old provider states URL if given
	// Otherwise point to proxy
	setupURL := request.ProviderStatesSetupURL
	if request.ProviderStatesSetupURL == "" {
		setupURL = fmt.Sprintf("%s://localhost:%d/__setup", u.Scheme, port)
	}

	// Construct verifier request
	verificationRequest := types.VerifyRequest{
		ProviderBaseURL:            fmt.Sprintf("%s://localhost:%d", u.Scheme, port), //
		PactURLs:                   request.PactURLs,
		BrokerURL:                  request.BrokerURL,
		Tags:                       request.Tags,
		BrokerUsername:             request.BrokerUsername,
		BrokerPassword:             request.BrokerPassword,
		BrokerToken:                request.BrokerToken,
		PublishVerificationResults: request.PublishVerificationResults,
		ProviderVersion:            request.ProviderVersion,
		ProviderStatesSetupURL:     setupURL,
	}

	if request.Provider == "" {
		verificationRequest.Provider = p.Provider
	}

	portErr := waitForPort(port, "tcp", "localhost", p.ClientTimeout,
		fmt.Sprintf(`Timed out waiting for http verification proxy on port %d - check for errors`, port))

	if portErr != nil {
		log.Fatal("Error:", err)
		return res, portErr
	}

	log.Println("[DEBUG] pact provider verification")

	return p.pactClient.VerifyProvider(verificationRequest)
}
func (p *Pact) VerifyProviderRaw(request types.VerifyRequest) (types.ProviderVerifierResponse, error) {
	p.Setup(false)
	var res types.ProviderVerifierResponse

	u, err := url.Parse(request.ProviderBaseURL)

	if err != nil {
		return res, err
	}

	m := []proxy.Middleware{}

	if request.BeforeEach != nil {
		m = append(m, BeforeEachMiddleware(request.BeforeEach))
	}

	if request.AfterEach != nil {
		m = append(m, AfterEachMiddleware(request.AfterEach))
	}

	if len(request.StateHandlers) > 0 {
		m = append(m, stateHandlerMiddleware(request.StateHandlers))
	}

	if request.RequestFilter != nil {
		m = append(m, request.RequestFilter)
	}

	// Configure HTTP Verification Proxy
	opts := proxy.Options{
		TargetAddress: fmt.Sprintf("%s:%s", u.Hostname(), u.Port()),
		TargetScheme:  u.Scheme,
		Middleware:    m,
	}

	// Starts the message wrapper API with hooks back to the state handlers
	// This maps the 'description' field of a message pact, to a function handler
	// that will implement the message producer. This function must return an object and optionally
	// and error. The object will be marshalled to JSON for comparison.
	port, err := proxy.HTTPReverseProxy(opts)

	// Backwards compatibility, setup old provider states URL if given
	// Otherwise point to proxy
	setupURL := request.ProviderStatesSetupURL
	if request.ProviderStatesSetupURL == "" {
		setupURL = fmt.Sprintf("%s://localhost:%d/__setup", u.Scheme, port)
	}

	// Construct verifier request
	verificationRequest := types.VerifyRequest{
		ProviderBaseURL:            fmt.Sprintf("%s://localhost:%d", u.Scheme, port), //
		PactURLs:                   request.PactURLs,
		BrokerURL:                  request.BrokerURL,
		Tags:                       request.Tags,
		BrokerUsername:             request.BrokerUsername,
		BrokerPassword:             request.BrokerPassword,
		BrokerToken:                request.BrokerToken,
		PublishVerificationResults: request.PublishVerificationResults,
		ProviderVersion:            request.ProviderVersion,
		ProviderStatesSetupURL:     setupURL,
	}

	if request.Provider == "" {
		verificationRequest.Provider = p.Provider
	}

	portErr := waitForPort(port, "tcp", "localhost", p.ClientTimeout,
		fmt.Sprintf(`Timed out waiting for http verification proxy on port %d - check for errors`, port))

	if portErr != nil {
		log.Fatal("Error:", err)
		return res, portErr
	}

	log.Println("[DEBUG] pact provider verification")

	return p.pactClient.VerifyProvider(verificationRequest)
}
// VerifyProviderRaw reads the provided pact files and runs verification against
// a running Provider API, providing raw response from the Verification process.
//
// Order of events: BeforeEach, stateHandlers, requestFilter(pre <execute provider> post), AfterEach