communication

package
v0.0.0-...-1f8cd32 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: BSD-3-Clause, MIT Imports: 6 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoName occurs when the given name is empty
	ErrNoName = errors.New("name is required")
)

Functions

This section is empty.

Types

type CallContext

type CallContext interface {
	GetIdempotenceKey() string
	GetIdempotenceRequestTimestamp() *int64
	SetIdempotenceRequestTimestamp(*int64)
}

CallContext can be used to send extra information with a request, and to receive extra information from a response. Please note that this type is not thread-safe. Each request should get its own call context instance.

type Header struct {
	// contains filtered or unexported fields
}

Header represents a single response header. Immutable.

func NewHeader

func NewHeader(name, value string) (*Header, error)

NewHeader returns a Header with the given name and value

func (Header) Name

func (h Header) Name() string

Name returns the name of the header

func (Header) String

func (h Header) String() string

String is the implementation of the Stringer interface Format: 'name:value'

func (Header) Value

func (h Header) Value() string

Value returns the value of the header

type Headers

type Headers []Header

Headers represents a slice of Header

func (Headers) GetDispositionFilename

func (h Headers) GetDispositionFilename() string

GetDispositionFilename returns the content of the filename found in the Content-Disposition header, or the empty string if it couldn't have been found.

func (Headers) GetHeader

func (h Headers) GetHeader(headerName string) *Header

GetHeader searches for the headerName in the headers

func (Headers) GetHeaderValue

func (h Headers) GetHeaderValue(headerName string) string

GetHeaderValue searches for the header name and returns the value as string, or the empty string if it doesn't exist. This doesn't break HTTP support since headers can't have empty values

func (Headers) Len

func (h Headers) Len() int

Len represents the length of the slice

func (Headers) Less

func (h Headers) Less(i, j int) bool

Less checks if two positions are in lexicographic order

func (Headers) Swap

func (h Headers) Swap(i, j int)

Swap swaps two elements

type MultipartFormDataObject

type MultipartFormDataObject struct {
	// contains filtered or unexported fields
}

MultipartFormDataObject is a representation of a multipart/form-data object.

func NewMultipartFormDataObject

func NewMultipartFormDataObject() (*MultipartFormDataObject, error)

NewMultipartFormDataObject constructs a new MultipartFormDataObject

func (*MultipartFormDataObject) AddFile

func (multipart *MultipartFormDataObject) AddFile(parameterName string, file UploadableFile) error

AddFile adds a file parameter.

func (*MultipartFormDataObject) AddValue

func (multipart *MultipartFormDataObject) AddValue(parameterName string, value string) error

AddValue adds a value parameter.

func (*MultipartFormDataObject) GetBoundary

func (multipart *MultipartFormDataObject) GetBoundary() string

GetBoundary returns the boundary.

func (*MultipartFormDataObject) GetContentType

func (multipart *MultipartFormDataObject) GetContentType() string

GetContentType returns the content type.

func (*MultipartFormDataObject) GetFiles

func (multipart *MultipartFormDataObject) GetFiles() map[string]UploadableFile

GetFiles returns the files.

func (*MultipartFormDataObject) GetValues

func (multipart *MultipartFormDataObject) GetValues() map[string]string

GetValues returns the values.

type ResponseHandler

type ResponseHandler interface {
	Handle(statusCode int, headers []Header, reader io.Reader) (interface{}, error)
}

ResponseHandler is a handler for an incoming response

type ResponseHandlerFunc

type ResponseHandlerFunc func(statusCode int, headers []Header, reader io.Reader) (interface{}, error)

ResponseHandlerFunc is a handler function for an incoming response

func (ResponseHandlerFunc) Handle

func (f ResponseHandlerFunc) Handle(statusCode int, headers []Header, reader io.Reader) (interface{}, error)

Handle calls f(statusCode, headers, reader)

type UploadableFile

type UploadableFile struct {
	// contains filtered or unexported fields
}

UploadableFile represents a file that can be uploaded.

func NewUploadableFile

func NewUploadableFile(fileName string, content io.Reader, contentType string) (*UploadableFile, error)

NewUploadableFile creates an uploadable file with the given file name, content and content type, and an unspecified content length.

func NewUploadableFileWithLength

func NewUploadableFileWithLength(fileName string, content io.Reader, contentType string, contentLength int64) (*UploadableFile, error)

NewUploadableFileWithLength creates an uploadable file with the given file name, content, content type and content length.

func (*UploadableFile) GetContent

func (f *UploadableFile) GetContent() io.Reader

GetContent returns a reader with the file's content.

func (*UploadableFile) GetContentLength

func (f *UploadableFile) GetContentLength() int64

GetContentLength returns the file's content length, or -1 if not known.

func (*UploadableFile) GetContentType

func (f *UploadableFile) GetContentType() string

GetContentType returns the file's content type.

func (*UploadableFile) GetFileName

func (f *UploadableFile) GetFileName() string

GetFileName returns the name of the file.

Jump to

Keyboard shortcuts

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