http

package
v0.0.0-...-1892ce4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: GPL-3.0 Imports: 9 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 {
	SetBaseHeaders(headers map[string]string)
	WithHeaders(headers map[string]string) Request
	WithCookies(cookies []*http.Cookie) Request

	Get(ctx context.Context, endpoint string, params interface{}) (*http.Response, error)
	Post(ctx context.Context, endpoint string, body interface{}) (*http.Response, error)
	PostRaw(ctx context.Context, endpoint string, raw []byte) (*http.Response, error)
	Put(ctx context.Context, endpoint string, body interface{}) (*http.Response, error)
	PutRaw(ctx context.Context, endpoint string, raw []byte) (*http.Response, error)
	Patch(ctx context.Context, endpoint string, body interface{}) (*http.Response, error)
	PatchRaw(ctx context.Context, endpoint string, raw []byte) (*http.Response, error)
	Delete(ctx context.Context, endpoint string) (*http.Response, error)
}

func New

func New(cfg Config) Client

type Config

type Config struct {
	// Host including http protocol
	Host string
	// Timeout in milliseconds
	Timeout int
}

type Request

type Request interface {
	WithHeaders(headers map[string]string) Request
	WithCookies(cookies []*http.Cookie) Request

	Get(ctx context.Context, endpoint string, params interface{}) (*http.Response, error)
	Post(ctx context.Context, endpoint string, body interface{}) (*http.Response, error)
	PostRaw(ctx context.Context, endpoint string, raw []byte) (*http.Response, error)
	Put(ctx context.Context, endpoint string, body interface{}) (*http.Response, error)
	PutRaw(ctx context.Context, endpoint string, raw []byte) (*http.Response, error)
	Patch(ctx context.Context, endpoint string, body interface{}) (*http.Response, error)
	PatchRaw(ctx context.Context, endpoint string, raw []byte) (*http.Response, error)
	Delete(ctx context.Context, endpoint string) (*http.Response, error)
}

func NewRequest

func NewRequest(client *http.Client, baseURL string, headers map[string]string) Request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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