Documentation ¶
Index ¶
- func NewBase64() transport.Transport
- func NewNonDefault(h *http.Client) transport.Transport
- type HTTPSBase64Transport
- type HTTPSTransport
- type MockHTTPTransport
- func (m *MockHTTPTransport) CallCount() int
- func (m *MockHTTPTransport) Error(index int) error
- func (m *MockHTTPTransport) Errors() []error
- func (m *MockHTTPTransport) Request(index int) *http.Request
- func (m *MockHTTPTransport) Requests() []*http.Request
- func (m *MockHTTPTransport) Reset()
- func (m *MockHTTPTransport) RoundTrip(req *http.Request) (*http.Response, error)
- func (m *MockHTTPTransport) SetResponsePayload(payload []byte) int
- func (m *MockHTTPTransport) SetResponsePayloads(payloads [][]byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HTTPSBase64Transport ¶
type HTTPSBase64Transport struct {
// contains filtered or unexported fields
}
A HTTPSBase64Transport implements transport.Transport and performs request over HTTPS with also encoding requests and responses with Base64 encoding.
func (*HTTPSBase64Transport) Do ¶
Do performs the request to the HBCI server. If successful, it returns a populated transport.Response with the HTTP Response Body as Body and the request as Request.
Before sending the request it will be encoded with Base64 encoding. When receiving the response with a status code 200 it will decode the response with Base64 encoding. A non 200 status code will be returned as is, without decoding it from Base64.
type HTTPSTransport ¶
A HTTPSTransport implements transport.Transport and performs request over HTTPS
func New ¶
func New() *HTTPSTransport
New returns a HTTPSTransport. It sets http.DefaultClient as http.Client to perform requests to the HBCI server
type MockHTTPTransport ¶
type MockHTTPTransport struct {
// contains filtered or unexported fields
}
MockHTTPTransport implements a http.RoundTripper. It can be used to mock http.Client details.
func (*MockHTTPTransport) CallCount ¶
func (m *MockHTTPTransport) CallCount() int
CallCount returns the number of calls received by the transport.
func (*MockHTTPTransport) Error ¶
func (m *MockHTTPTransport) Error(index int) error
Error returns the error for the given index. If there are less errors than the index nil is returned.
func (*MockHTTPTransport) Errors ¶
func (m *MockHTTPTransport) Errors() []error
Errors returns all errors registered in the transport. If there is no registered error, an empty slice is returned.
func (*MockHTTPTransport) Request ¶
func (m *MockHTTPTransport) Request(index int) *http.Request
Request returns the http.Request for the current index. If there are less requests than the index nil is returned.
func (*MockHTTPTransport) Requests ¶
func (m *MockHTTPTransport) Requests() []*http.Request
Requests returns all http.Requests the transport has received. If there are no requests, an empty slice is returned.
func (*MockHTTPTransport) Reset ¶
func (m *MockHTTPTransport) Reset()
Reset resets the registered responses and the received requests. It also sets the callCount to zero.
func (*MockHTTPTransport) RoundTrip ¶
RoundTrip satisties the http.RoundTripper interface.
it will store the request to later retrospects and return the stored response or the stored error respectively. callCount will be incremented on each call.
func (*MockHTTPTransport) SetResponsePayload ¶
func (m *MockHTTPTransport) SetResponsePayload(payload []byte) int
SetResponsePayload registers a given payload in the transport. The payload will be encoded as Base64 and wrapped into a io.Reader. This also sets a status code of 200 and the error for the given call will be nil. The index of the response will be returned.
func (*MockHTTPTransport) SetResponsePayloads ¶
func (m *MockHTTPTransport) SetResponsePayloads(payloads [][]byte)
SetResponsePayloads registers multiple payloads in the transport. The payloads will be encoded as Base64 and wrapped into a io.Reader. This also sets a status code of 200 and the errors for the given calls will be nil. This method will reset any responses or errors previously registered.