client

package
v1.16.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BaseUrl             string
	Timeout             time.Duration
	MaxIdleConns        int
	MaxIdleConnsPerHost int
	IdleConnTimeout     time.Duration
	MaxConnsPerHost     int
}

type Request

type Request interface {
	Get(uri string) (Response, error)
	Post(uri string, body io.Reader) (Response, error)
	Put(uri string, body io.Reader) (Response, error)
	Delete(uri string, body io.Reader) (Response, error)
	Patch(uri string, body io.Reader) (Response, error)
	Head(uri string) (Response, error)
	Options(uri string) (Response, error)

	Accept(contentType string) Request
	AcceptJSON() Request
	AsForm() Request
	Bind(value any) Request
	Clone() Request
	FlushHeaders() Request
	ReplaceHeaders(headers map[string]string) Request
	WithBasicAuth(username, password string) Request
	WithContext(ctx context.Context) Request
	WithCookies(cookies []*http.Cookie) Request
	WithCookie(cookie *http.Cookie) Request
	WithHeader(key, value string) Request
	WithHeaders(map[string]string) Request
	WithQueryParameter(key, value string) Request
	WithQueryParameters(map[string]string) Request
	WithQueryString(query string) Request
	WithoutHeader(key string) Request
	WithToken(token string, ttype ...string) Request
	WithoutToken() Request
	WithUrlParameter(key, value string) Request
	WithUrlParameters(map[string]string) Request
}

type Response

type Response interface {
	Body() (string, error)
	ClientError() bool
	Cookie(name string) *http.Cookie
	Cookies() []*http.Cookie
	Failed() bool
	Header(name string) string
	Headers() http.Header
	Json() (map[string]any, error)
	Redirect() bool
	ServerError() bool
	Status() int
	Successful() bool

	OK() bool                  // 200 OK
	Created() bool             // 201 Created
	Accepted() bool            // 202 Accepted
	NoContent() bool           // 204 No Content
	MovedPermanently() bool    // 301 Moved Permanently
	Found() bool               // 302 Found
	BadRequest() bool          // 400 Bad Request
	Unauthorized() bool        // 401 Unauthorized
	PaymentRequired() bool     // 402 Payment Required
	Forbidden() bool           // 403 Forbidden
	NotFound() bool            // 404 Not Found
	RequestTimeout() bool      // 408 Request Timeout
	Conflict() bool            // 409 Conflict
	UnprocessableEntity() bool // 422 Unprocessable Entity
	TooManyRequests() bool     // 429 Too Many Requests
}

Jump to

Keyboard shortcuts

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