common

package
v0.0.0-...-e5ad554 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 17 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 ContainsString

func ContainsString(stringList []string, s string) bool

func GetIndentJson

func GetIndentJson(v interface{}) (string, error)

func GetStructTags

func GetStructTags(i interface{}) []string

func IsUUID

func IsUUID(s string) bool

func LoadUserData

func LoadUserData(file string) (string, error)

func RaiseIfError

func RaiseIfError(err error, msg string)

func UrlJoin

func UrlJoin(path ...string) string

Types

type BaseResponse

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

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
	Size int
	// contains filtered or unexported fields
}

func (*ReaderWithProcess) PrintProcess

func (reader *ReaderWithProcess) PrintProcess(r int)

func (*ReaderWithProcess) Read

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

type Resource

type Resource struct {
	Id          string `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Status      string `json:"status,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`
	Created     string `json:"created,omitempty"`
	Updated     string `json:"updated,omitempty"`
	ProjectId   string `json:"project_id,omitempty"`
	TenantId    string `json:"tenant_id,omitempty"`
	UserId      string `json:"user_id,omitempty"`
}

func (Resource) GetStructTags

func (resource Resource) GetStructTags() []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

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 RestfulRequest

type RestfulRequest struct {
	Endpoint    string
	Method      string
	Resource    string
	Id          string
	Query       url.Values
	Body        []byte
	Headers     map[string]string
	ShowProcess bool
}

func NewIndexRequest

func NewIndexRequest(endpoint string, query url.Values, headers map[string]string,
) RestfulRequest

func NewResourceCreateRequest

func NewResourceCreateRequest(endpoint string, resource string, body []byte,
	headers map[string]string,
) RestfulRequest

func NewResourceDeleteRequest

func NewResourceDeleteRequest(endpoint string, resource string, id string,
	headers map[string]string,
) RestfulRequest

func NewResourceListRequest

func NewResourceListRequest(endpoint string, resource string, query url.Values,
	headers map[string]string,
) RestfulRequest

func NewResourcePatchRequest

func NewResourcePatchRequest(endpoint string, resource string, id string, body []byte,
	headers map[string]string,
) RestfulRequest

func NewResourcePutRequest

func NewResourcePutRequest(endpoint string, resource string, id string, body []byte,
	headers map[string]string,
) RestfulRequest

func NewResourceShowRequest

func NewResourceShowRequest(endpoint string, resource string, id string,
	headers map[string]string,
) RestfulRequest

func (*RestfulRequest) Url

func (request *RestfulRequest) Url() (string, error)

type Session

type Session struct {
	Timeout time.Duration
}

type WriterWithProces

type WriterWithProces struct {
	io.Writer
	Size int
	// contains filtered or unexported fields
}

func (*WriterWithProces) PrintProcess

func (reader *WriterWithProces) PrintProcess(r int)

func (*WriterWithProces) Write

func (reader *WriterWithProces) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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