http

package
v0.0.0-...-edb8809 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetFrom(path string) (*http.Response, error)
	PostTo(path string, body io.Reader) (*http.Response, error)
	PutTo(path string, body io.Reader) (*http.Response, error)
	DeleteFrom(path string) (*http.Response, error)

	GetRequest(path string) (*http.Request, error)
	PostRequest(path string, body io.Reader) (*http.Request, error)
	PutRequest(path string, body io.Reader) (*http.Request, error)
	DeleteRequest(path string) (*http.Request, error)

	GetFromWithContext(ctx context.Context, path string) (*http.Response, error)
	PostToWithContext(ctx context.Context, path string, body io.Reader) (*http.Response, error)
	PutToWithContext(ctx context.Context, path string, body io.Reader) (*http.Response, error)
	DeleteFromWithContext(ctx context.Context, path string) (*http.Response, error)
}

Client provides a high-level API for working with HTTP requests and constructing them.

type HTTPClient

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

HTTPClient wraps the underlying http.Client and it's HTTPConfig.

func NewDefaultHTTPClient

func NewDefaultHTTPClient(baseURL string) *HTTPClient

func NewHTTPClient

func NewHTTPClient(config *HTTPConfig) *HTTPClient

*

  • Create a new HTTPClient with a custom transport for clean resource usage

func (*HTTPClient) DeleteFrom

func (h *HTTPClient) DeleteFrom(path string) (*http.Response, error)

func (*HTTPClient) DeleteFromWithContext

func (h *HTTPClient) DeleteFromWithContext(ctx context.Context, path string) (*http.Response, error)

func (*HTTPClient) DeleteRequest

func (h *HTTPClient) DeleteRequest(path string) (*http.Request, error)

func (*HTTPClient) GetFrom

func (h *HTTPClient) GetFrom(path string) (*http.Response, error)

Interface implementations

func (*HTTPClient) GetFromWithContext

func (h *HTTPClient) GetFromWithContext(ctx context.Context, path string) (*http.Response, error)

func (*HTTPClient) GetRequest

func (h *HTTPClient) GetRequest(path string) (*http.Request, error)

func (*HTTPClient) PostRequest

func (h *HTTPClient) PostRequest(path string, body io.Reader) (*http.Request, error)

func (*HTTPClient) PostTo

func (h *HTTPClient) PostTo(path string, body io.Reader) (*http.Response, error)

func (*HTTPClient) PostToWithContext

func (h *HTTPClient) PostToWithContext(ctx context.Context, path string, body io.Reader) (*http.Response, error)

func (*HTTPClient) PutRequest

func (h *HTTPClient) PutRequest(path string, body io.Reader) (*http.Request, error)

func (*HTTPClient) PutTo

func (h *HTTPClient) PutTo(path string, body io.Reader) (*http.Response, error)

func (*HTTPClient) PutToWithContext

func (h *HTTPClient) PutToWithContext(ctx context.Context, path string, body io.Reader) (*http.Response, error)

type HTTPConfig

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

HTTPConfig holds the base configuration for the HTTPClient.

func DefaultHTTPConfig

func DefaultHTTPConfig(baseURL string) *HTTPConfig

func NewHTTPConfig

func NewHTTPConfig(baseURL string, username string, password string, accept string) *HTTPConfig

type HttpError

type HttpError struct {
	Message    string
	StatusCode int
}

func (HttpError) Error

func (e HttpError) Error() string

type NotFoundError

type NotFoundError struct {
	Message string
	Url     string
}

func (NotFoundError) Error

func (e NotFoundError) Error() string

type RemoteError

type RemoteError struct {
	Host string
	// contains filtered or unexported fields
}

func (RemoteError) Error

func (e RemoteError) Error() string

type UnauthorizedError

type UnauthorizedError struct {
	Message string
	Url     string
	Status  int
}

func (UnauthorizedError) Error

func (e UnauthorizedError) Error() string

Jump to

Keyboard shortcuts

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