request

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package request provides clients for requesting data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

Types

type ContextLogger

type ContextLogger interface {
	Debugf(ctx context.Context, format string, args ...interface{})
	Infof(ctx context.Context, format string, args ...interface{})
	Warningf(ctx context.Context, format string, args ...interface{})
	Errorf(ctx context.Context, format string, args ...interface{})
}

ContextLogger interface used in this package with request context.

func NewContextLogger

func NewContextLogger(lev LogLevel) ContextLogger

NewContextLogger ...

type ErrHTTP

type ErrHTTP struct {
	StatusCode int
}

ErrHTTP is an HTTP Error.

func (ErrHTTP) Error

func (e ErrHTTP) Error() string

type ErrTemporary

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

ErrTemporary means there was a temporary error

func NewErrTemporary

func NewErrTemporary(msg string) ErrTemporary

NewErrTemporary creates temporary error.

func (ErrTemporary) Error

func (e ErrTemporary) Error() string

func (ErrTemporary) Temporary

func (e ErrTemporary) Temporary() bool

Temporary returns true.

type ErrTimeout

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

ErrTimeout is a timeout error.

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger interface used in this package.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...

type MockRequestor

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

MockRequestor ...

func NewMockRequestor

func NewMockRequestor() *MockRequestor

NewMockRequestor with mocked responses.

func (*MockRequestor) RequestURLString

func (r *MockRequestor) RequestURLString(ctx context.Context, urs string) ([]byte, error)

RequestURLString ...

func (*MockRequestor) Response

func (r *MockRequestor) Response(url string) ([]byte, error)

Response returns mocked response.

func (*MockRequestor) SetError

func (r *MockRequestor) SetError(url string, err error)

SetError ...

func (*MockRequestor) SetResponse

func (r *MockRequestor) SetResponse(url string, b []byte)

SetResponse ...

type Requestor

type Requestor interface {
	RequestURLString(ctx context.Context, urs string) ([]byte, error)
}

Requestor defines how to get bytes from a URL.

func NewHTTPRequestor

func NewHTTPRequestor() Requestor

NewHTTPRequestor creates a Requestor for HTTP URLs.

Jump to

Keyboard shortcuts

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