transport

package
v0.1.4-beta1 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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func func(*Request) (*Response, error)

The Func type is an adapter to allow the use of ordinary functions as Transport handlers. If f is a function with the appropriate signature, Func(f) is a Transport that calls f.

func (Func) Do

func (fn Func) Do(req *Request) (*Response, error)

Do calls fn(req).

type Middleware

type Middleware func(Transport) Transport

Middleware defines the interface for writing middleware for transports

type Request

type Request struct {
	// URL specifies the URI being requested
	//
	// For the sake of simplicity this is a string instead a *url.URL right now
	URL string
	// Body is the request's body.
	//
	// Body has always to be non-nil
	Body io.ReadCloser
}

A Request represents a client request to a HBCI server

type Response

type Response struct {
	// The SegmentExtractor can be used to conveniently query segments from the
	// Response.
	//
	// Right now the Response embeds the SegmentExtractor, which violates the SRP.
	// Future Response types may get rid of it.
	*segment.SegmentExtractor
	// Request is the request that was sent to obtain this Response.
	// Request's Body is nil (having already been consumed).
	Request *Request
	// MarshaledResponse represents the body payload as byte slice. It's strongly
	// discouraged to use that as it may or may not be populated by the Transport.
	//
	// It's only there for legacy reasons.
	MarshaledResponse []byte
	// Body represents the response body.
	Body io.ReadCloser
}

A Response represents a server response from a HBCI server

func ReadResponse

func ReadResponse(r *bufio.Reader, req *Request) (*Response, error)

ReadResponse reads and returns a Response from r. It populates the embedded SegmentExtractor to have it ready to use.

func (*Response) IsEncrypted

func (h *Response) IsEncrypted() bool

IsEncrypted returns whether the response contains an encrypted message. This method will panic when the SegmentExtractor is not populated.

type Transport

type Transport interface {
	Do(*Request) (*Response, error)
}

Transport defines an interface over the various ways data got exchanged with HBCI servers. It is used by higher level implementations to perform requests against the bank servers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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