common

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressIDBytes = 20
	AddressBytes   = AddressIDBytes + 1
)
View Source
const (
	DefaultHttpNetwork = "tcp"
)
View Source
const PrefixLen = 4

Variables

View Source
var (
	DefaultJsonTemplate = NewJsonTemplate("default")
)

Functions

func EqualsSyscallErrno

func EqualsSyscallErrno(err error, sen syscall.Errno) bool

func HasContentType

func HasContentType(h http.Header, mimetype string) bool

func HexPre

func HexPre(bs []byte) string

HexPre returns hexadecimal string of prefix of byte slice bs.

func IsBrokenPipeError

func IsBrokenPipeError(err error) bool

is 'close by client' error

func IsConnectRefusedError

func IsConnectRefusedError(err error) bool

func MultipartCopy

func MultipartCopy(mw *multipart.Writer, fieldName string, r io.Reader) error

func MultipartFile

func MultipartFile(mw *multipart.Writer, fieldName, fileName string) error

func MultipartJson

func MultipartJson(mw *multipart.Writer, fieldName string, v interface{}) error

func NoneMiddlewareFunc

func NoneMiddlewareFunc(next echo.HandlerFunc) echo.HandlerFunc

func StrLeft

func StrLeft(n int, s string) string

func StrToCamelCase

func StrToCamelCase(str string) string

func StrToSnakeCase

func StrToSnakeCase(str string) string

func Unauthorized

func Unauthorized(readOnly bool) echo.MiddlewareFunc

func UrlWithParams

func UrlWithParams(reqUrl string, reqParams ...*url.Values) string

func WrapFunc

func WrapFunc(fs ...func()) echo.MiddlewareFunc

func WrapHandler

func WrapHandler(hs ...http.Handler) echo.HandlerFunc

Types

type Address

type Address [AddressBytes]byte

func NewAccountAddress

func NewAccountAddress(b []byte) *Address

func NewAccountAddressFromPublicKey

func NewAccountAddressFromPublicKey(pubKey *crypto.PublicKey) *Address

func NewAddress

func NewAddress(b []byte) *Address

func NewAddressFromString

func NewAddressFromString(s string) *Address

func NewContractAddress

func NewContractAddress(b []byte) *Address

func (*Address) Bytes

func (a *Address) Bytes() []byte

func (*Address) Equal

func (a *Address) Equal(a2 *Address) bool

func (*Address) ID

func (a *Address) ID() []byte

BytesPart returns part of address without type prefix.

func (*Address) IsContract

func (a *Address) IsContract() bool

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (*Address) RLPDecodeSelf

func (a *Address) RLPDecodeSelf(d codec.Decoder) error

func (*Address) RLPEncodeSelf

func (a *Address) RLPEncodeSelf(e codec.Encoder) error

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte) error

func (*Address) SetString

func (a *Address) SetString(s string) error

func (*Address) SetTypeAndID

func (a *Address) SetTypeAndID(ic bool, id []byte) error

func (*Address) String

func (a *Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

type HexBytes

type HexBytes []byte

func SliceOfHexBytes

func SliceOfHexBytes(bss [][]byte) []HexBytes

func (HexBytes) Bytes

func (hs HexBytes) Bytes() []byte

func (HexBytes) MarshalJSON

func (hs HexBytes) MarshalJSON() ([]byte, error)

func (HexBytes) String

func (hs HexBytes) String() string

func (*HexBytes) UnmarshalJSON

func (hs *HexBytes) UnmarshalJSON(b []byte) error

type HexInt

type HexInt struct {
	big.Int
}

func NewHexInt

func NewHexInt(v int64) *HexInt

func (*HexInt) Bytes

func (i *HexInt) Bytes() []byte

func (*HexInt) Clone

func (i *HexInt) Clone() HexInt

func (*HexInt) MarshalBinary

func (i *HexInt) MarshalBinary() (data []byte, err error)

func (HexInt) MarshalJSON

func (i HexInt) MarshalJSON() ([]byte, error)

func (*HexInt) SetBytes

func (i *HexInt) SetBytes(bs []byte) *big.Int

func (HexInt) String

func (i HexInt) String() string

func (*HexInt) UnmarshalBinary

func (i *HexInt) UnmarshalBinary(data []byte) error

func (*HexInt) UnmarshalJSON

func (i *HexInt) UnmarshalJSON(b []byte) error

type HexInt16

type HexInt16 struct {
	Value int16
}

func (HexInt16) Bytes

func (i HexInt16) Bytes() []byte

func (HexInt16) MarshalJSON

func (i HexInt16) MarshalJSON() ([]byte, error)

func (*HexInt16) RLPDecodeSelf

func (i *HexInt16) RLPDecodeSelf(d codec.Decoder) error

func (*HexInt16) RLPEncodeSelf

func (i *HexInt16) RLPEncodeSelf(e codec.Encoder) error

func (HexInt16) String

func (i HexInt16) String() string

func (*HexInt16) UnmarshalJSON

func (i *HexInt16) UnmarshalJSON(b []byte) error

type HexInt32

type HexInt32 struct {
	Value int32
}

func (HexInt32) MarshalJSON

func (i HexInt32) MarshalJSON() ([]byte, error)

func (*HexInt32) RLPDecodeSelf

func (i *HexInt32) RLPDecodeSelf(d codec.Decoder) error

func (*HexInt32) RLPEncodeSelf

func (i *HexInt32) RLPEncodeSelf(e codec.Encoder) error

func (HexInt32) String

func (i HexInt32) String() string

func (*HexInt32) UnmarshalJSON

func (i *HexInt32) UnmarshalJSON(b []byte) error

type HexInt64

type HexInt64 struct {
	Value int64
}

func (HexInt64) MarshalJSON

func (i HexInt64) MarshalJSON() ([]byte, error)

func (*HexInt64) RLPDecodeSelf

func (i *HexInt64) RLPDecodeSelf(d codec.Decoder) error

func (*HexInt64) RLPEncodeSelf

func (i *HexInt64) RLPEncodeSelf(e codec.Encoder) error

func (HexInt64) String

func (i HexInt64) String() string

func (*HexInt64) UnmarshalJSON

func (i *HexInt64) UnmarshalJSON(b []byte) error

type HexUint16

type HexUint16 struct {
	Value uint16
}

func (HexUint16) Bytes

func (i HexUint16) Bytes() []byte

func (HexUint16) MarshalJSON

func (i HexUint16) MarshalJSON() ([]byte, error)

func (*HexUint16) RLPDecodeSelf

func (i *HexUint16) RLPDecodeSelf(d codec.Decoder) error

func (*HexUint16) RLPEncodeSelf

func (i *HexUint16) RLPEncodeSelf(e codec.Encoder) error

func (HexUint16) String

func (i HexUint16) String() string

func (*HexUint16) UnmarshalJSON

func (i *HexUint16) UnmarshalJSON(b []byte) error

type HexUint32

type HexUint32 struct {
	Value uint32
}

func (HexUint32) MarshalJSON

func (i HexUint32) MarshalJSON() ([]byte, error)

func (*HexUint32) RLPDecodeSelf

func (i *HexUint32) RLPDecodeSelf(d codec.Decoder) error

func (*HexUint32) RLPEncodeSelf

func (i *HexUint32) RLPEncodeSelf(e codec.Encoder) error

func (HexUint32) String

func (i HexUint32) String() string

func (*HexUint32) UnmarshalJSON

func (i *HexUint32) UnmarshalJSON(b []byte) error

type HexUint64

type HexUint64 struct {
	Value uint64
}

func (HexUint64) MarshalJSON

func (i HexUint64) MarshalJSON() ([]byte, error)

func (*HexUint64) RLPDecodeSelf

func (i *HexUint64) RLPDecodeSelf(d codec.Decoder) error

func (*HexUint64) RLPEncodeSelf

func (i *HexUint64) RLPEncodeSelf(e codec.Encoder) error

func (HexUint64) String

func (i HexUint64) String() string

func (*HexUint64) UnmarshalJSON

func (i *HexUint64) UnmarshalJSON(b []byte) error

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient(address string, contextPath string) *HttpClient

func (*HttpClient) Delete

func (c *HttpClient) Delete(reqUrl string, respPtr interface{}) (resp *http.Response, err error)

func (*HttpClient) Do

func (c *HttpClient) Do(method, reqUrl string, reqPtr, respPtr interface{}) (resp *http.Response, err error)

func (*HttpClient) Get

func (c *HttpClient) Get(reqUrl string, respPtr interface{}, reqParams ...*url.Values) (resp *http.Response, err error)

func (*HttpClient) Post

func (c *HttpClient) Post(reqUrl string, respPtr interface{}) (resp *http.Response, err error)

func (*HttpClient) PostWithFile

func (c *HttpClient) PostWithFile(reqUrl string, reqPtr interface{}, fieldName, fileName string, respPtr interface{}) (resp *http.Response, err error)

func (*HttpClient) PostWithJson

func (c *HttpClient) PostWithJson(reqUrl string, reqPtr interface{}, respPtr interface{}) (resp *http.Response, err error)

func (*HttpClient) PostWithReader

func (c *HttpClient) PostWithReader(reqUrl string, reqPtr interface{}, fieldName string, r io.Reader, respPtr interface{}) (resp *http.Response, err error)

func (*HttpClient) Stream

func (c *HttpClient) Stream(reqUrl string, reqPtr, respPtr interface{},
	respFunc HttpStreamFunc, cancelCh <-chan bool, reqParams ...*url.Values) (resp *http.Response, err error)

type HttpError

type HttpError struct {
	// contains filtered or unexported fields
}

func NewHttpError

func NewHttpError(r *http.Response) *HttpError

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) Response

func (e *HttpError) Response() []byte

func (*HttpError) StatusCode

func (e *HttpError) StatusCode() int

type HttpServer

type HttpServer struct {
	// contains filtered or unexported fields
}

func NewHttpServer

func NewHttpServer(address string, e *echo.Echo) *HttpServer

func (*HttpServer) Address

func (s *HttpServer) Address() string

func (*HttpServer) Echo

func (s *HttpServer) Echo() *echo.Echo

func (*HttpServer) ListenAddress

func (s *HttpServer) ListenAddress() string

func (*HttpServer) Start

func (s *HttpServer) Start() error

func (*HttpServer) Stop

func (s *HttpServer) Stop() error

type HttpStreamFunc

type HttpStreamFunc func(respPtr interface{}) error

type JsonTemplate

type JsonTemplate struct {
	*template.Template
}

func NewJsonTemplate

func NewJsonTemplate(name string) *JsonTemplate

func (*JsonTemplate) Response

func (t *JsonTemplate) Response(format string, v interface{}, resp *echo.Response) error

type RawHexBytes

type RawHexBytes []byte

func (RawHexBytes) Bytes

func (rh RawHexBytes) Bytes() []byte

func (RawHexBytes) MarshalJSON

func (rh RawHexBytes) MarshalJSON() ([]byte, error)

func (RawHexBytes) String

func (rh RawHexBytes) String() string

func (*RawHexBytes) UnmarshalJSON

func (rh *RawHexBytes) UnmarshalJSON(b []byte) error

Directories

Path Synopsis
Use this code snippet in your app.
Use this code snippet in your app.

Jump to

Keyboard shortcuts

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