http

package
v0.0.0-...-f0105ca Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(e error) bool

func NewRequest

func NewRequest(ctx context.Context, method string, url string, body io.Reader, opts ...RequestOption) (*http.Request, error)

func NewUnexpectedStatusErr

func NewUnexpectedStatusErr(resp *http.Response) error

NewUnexpectedStatusErr creates an ErrUnexpectedStatus from HTTP response

func ResponseToFile

func ResponseToFile(resp *http.Response, file string) error

Types

type Client

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

func New

func New(opts ...Option) *Client

func (Client) Do

func (client Client) Do(req *http.Request) (*http.Response, error)

func (Client) Get

func (client Client) Get(ctx context.Context, url string, opts ...RequestOption) (*http.Response, error)

func (Client) Head

func (client Client) Head(ctx context.Context, url string, opts ...RequestOption) (*http.Response, error)

func (Client) Post

func (client Client) Post(ctx context.Context, url string, body io.Reader, opts ...RequestOption) (*http.Response, error)

func (Client) Put

func (client Client) Put(ctx context.Context, url string, body io.Reader, opts ...RequestOption) (*http.Response, error)

type ErrUnexpectedStatus

type ErrUnexpectedStatus struct {
	Status        string `json:"status"`
	StatusCode    int    `json:"statusCode"`
	Body          []byte `json:"body,omitempty"`
	RequestURL    string `json:"requestURL,omitempty"`
	RequestMethod string `json:"requestMethod,omitempty"`
}

ErrUnexpectedStatus is returned if a registry API request returned with unexpected HTTP status

func (*ErrUnexpectedStatus) Error

func (e *ErrUnexpectedStatus) Error() string

type Option

type Option func(*Client)

func WithAuthCreds

func WithAuthCreds(creds func(string) (string, string, error)) Option

func WithInsecure

func WithInsecure() Option

type RequestOption

type RequestOption func(*http.Request)

func WithAccept

func WithAccept(allow ...string) RequestOption

func WithContentType

func WithContentType(contentType string) RequestOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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