http

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHttpClient

func GetHttpClient(config *tls.Config) *http.Client

func GetTLSConfigGlobal

func GetTLSConfigGlobal() (globalConfig *tls.Config)

GetTLSConfigGlobal return the pointer to global config

func SetInsuredGlobal

func SetInsuredGlobal()

func SetRootCAs

func SetRootCAs(config *tls.Config, rootPEMs []string)

Types

type Error added in v1.6.3

type Error struct {
	Code    StatusCode
	Message string
	Data    interface{} `json:"data,omitempty"`
}

func BadRequest added in v1.6.3

func BadRequest(msg string) *Error

func InternalServerError added in v1.6.3

func InternalServerError(msg string) *Error

func ServiceUnavailable added in v1.6.3

func ServiceUnavailable(msg string) *Error

func (*Error) Error added in v1.6.3

func (e *Error) Error() string

type Response

type Response http.Response

func Get

func Get(url string, client *http.Client) Response

func Post

func Post(url string, contentType string, body io.Reader, client *http.Client) Response

func PostForm added in v1.5.4

func PostForm(url string, data url.Values, client *http.Client) Response

func PostJson

func PostJson(url string, body interface{}, client *http.Client) Response

func (Response) BodyBytes

func (t Response) BodyBytes() []byte

func (Response) Trim

func (t Response) Trim() ResponseJSON

type ResponseJSON

type ResponseJSON struct {
	StatusCode int // e.g. 200
	Body       string
}

type StatusCode added in v1.6.3

type StatusCode int

StatusCode A http status code

func (StatusCode) String added in v1.6.3

func (c StatusCode) String() string

Jump to

Keyboard shortcuts

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