transport

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2018 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBase64

func NewBase64() transport.Transport

NewBase64 returns a HTTPSBase64Transport. It sets http.DefaultClient as http.Client to perform requests to the HBCI server.

Each request will be encoded and each response will be decoded with Base64 encoding.

func NewNonDefault

func NewNonDefault(h *http.Client) transport.Transport

NewNonDefault returns a HTTPSTransport which uses the given http.Client to perform requests to the HBCO server

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

type HTTPSTransport struct {
	HTTPClient *http.Client
}

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

func (*HTTPSTransport) 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

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

func (m *MockHTTPTransport) RoundTrip(req *http.Request) (*http.Response, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL