github.com/webdestroya/awsmocker@v0.2.6/mocked_endpoint.go (about)

     1  package awsmocker
     2  
     3  type MockedEndpoint struct {
     4  	Request  *MockedRequest
     5  	Response *MockedResponse
     6  }
     7  
     8  func (m *MockedEndpoint) prep() {
     9  	m.Response.action = m.Request.Action
    10  
    11  	m.Response.prep()
    12  	m.Request.prep()
    13  
    14  }
    15  
    16  func (m *MockedEndpoint) matchRequest(rr *ReceivedRequest) bool {
    17  	return m.Request.matchRequest(rr)
    18  }
    19  
    20  func (m *MockedEndpoint) getResponse(rr *ReceivedRequest) *httpResponse {
    21  	return m.Response.getResponse(rr)
    22  }
    23  
    24  func NewSimpleMockedEndpoint(service, action string, responseObj any) *MockedEndpoint {
    25  	return &MockedEndpoint{
    26  		Request: &MockedRequest{
    27  			Service: service,
    28  			Action:  action,
    29  		},
    30  		Response: &MockedResponse{
    31  			Body: responseObj,
    32  		},
    33  	}
    34  }