utility

package
v0.0.0-...-2ab8be3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CODE_404 = 404
)

Variables

This section is empty.

Functions

func CloneHeaders

func CloneHeaders(h1 map[string]string, h2 map[string]string) map[string]string

func ColorString

func ColorString(text string) string

func EncodeHeaders

func EncodeHeaders(headers http.Header) string

func GetStructTags

func GetStructTags(i interface{}) []string

func LoadUserData

func LoadUserData(file string) (string, error)

func LogError

func LogError(err error, message string, exit bool)

func RaiseIfError

func RaiseIfError(err error, msg string)

func ReadResponseBody

func ReadResponseBody(resp *http.Response) string

func UnmarshalResponse

func UnmarshalResponse(resp *http.Response, o interface{}) error

func UrlJoin

func UrlJoin(path ...string) string

func UrlValues

func UrlValues(m map[string]string) url.Values

func VersionUrl

func VersionUrl(endpoint, version string) string

Types

type BaseResponse

type BaseResponse interface {
	BodyString()
	GetHeader()
	BodyUnmarshal(object interface{})
}

type ColorFormater

type ColorFormater struct {
	Green  []string
	Yellow []string
	Red    []string
}
var BaseColorFormatter ColorFormater

func (ColorFormater) Format

func (cf ColorFormater) Format(text string) string

type HttpError

type HttpError struct {
	Status  int
	Reason  string
	Message string
}

func (HttpError) Error

func (err HttpError) Error() string

func (HttpError) IsNotFound

func (err HttpError) IsNotFound() bool

type ReaderWithProcess

type ReaderWithProcess struct {
	io.Reader
	Bar *pb.ProgressBar
}

func NewProcessReader

func NewProcessReader(reader io.ReadCloser, size int) *ReaderWithProcess

func (*ReaderWithProcess) Read

func (reader *ReaderWithProcess) Read(p []byte) (int, error)

type Request

type Request struct {
	Method  string
	Url     string
	Body    []byte
	Query   url.Values
	Headers map[string]string
}

type Response

type Response struct {
	Status  int
	Reason  string
	Body    []byte
	Headers http.Header
	// contains filtered or unexported fields
}

func (Response) BodyString

func (resp Response) BodyString() string

func (Response) BodyUnmarshal

func (resp Response) BodyUnmarshal(object interface{}) error

func (Response) GetContentLength

func (resp Response) GetContentLength() int

func (Response) GetHeader

func (resp Response) GetHeader(key string) string

func (Response) IsNotFound

func (resp Response) IsNotFound() bool

func (*Response) JudgeStatus

func (resp *Response) JudgeStatus() error

func (*Response) ReadAll

func (resp *Response) ReadAll() error

func (Response) SaveBody

func (resp Response) SaveBody(file *os.File, process bool) error

func (*Response) SetBodyReader

func (resp *Response) SetBodyReader(reader io.ReadCloser)

type RestfulClient

type RestfulClient struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func (RestfulClient) Delete

func (c RestfulClient) Delete(url string, headers map[string]string) (*Response, error)

func (RestfulClient) Get

func (c RestfulClient) Get(url string, query url.Values, headers map[string]string) (*Response, error)

func (RestfulClient) Post

func (c RestfulClient) Post(url string, body []byte, headers map[string]string,
) (*Response, error)

func (RestfulClient) Put

func (c RestfulClient) Put(url string, body []byte, headers map[string]string) (*Response, error)

func (RestfulClient) Request

func (c RestfulClient) Request(req *http.Request) (*Response, error)

type Session

type Session struct {
	Timeout time.Duration
}

type StringRing

type StringRing struct {
	Items []string
	// contains filtered or unexported fields
}

func (*StringRing) Next

func (r *StringRing) Next() string

func (*StringRing) Sample

func (r *StringRing) Sample(count int) []string

Jump to

Keyboard shortcuts

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