clientocol

package
v0.0.0-...-ba00fc6 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderQiuUser  = "X-Qiu-User"
	HeaderQiuPrior = "X-Qiu-Prior"
	HeaderQiuCity  = "X-Qiu-City"
	HeaderQiuIp    = "X-Qiu-Ip"
	HeaderQiuHost  = "X-Qiu-Host"
)

Variables

This section is empty.

Functions

func Close

func Close()

func CloseDB

func CloseDB()

func HTTPRequest

func HTTPRequest[T any](req *http.Request, respBody *T) error

func InitDB

func InitDB(dsn string) *sqlx.DB

func InitRedis

func InitRedis(addr, pwd string, idx int) *redis.Client

func Logger

func Logger() routtp.Handler

Logger 接收 routtp 框架默认的日志

func RawHTTPRequest

func RawHTTPRequest(req *http.Request) (*http.Response, error)

func Recovery

func Recovery() routtp.Handler

Recovery recover 掉项目可能出现的 panic

func Start

func Start(srv *http.Server)

func Transaction

func Transaction(dbx *sqlx.DB, fc func(*sqlx.Tx) error) error

Types

type Client

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

func NewClient

func NewClient() *Client

func (*Client) Invoke

func (client *Client) Invoke(meth string, url string, bReq any, sh ...func(*http.Header)) *Req

func (*Client) WithErrDecode

func (client *Client) WithErrDecode(f func(*http.Response) error)

func (*Client) WithHeader

func (client *Client) WithHeader(key string, value *string) *Client

func (*Client) WithRedirct

func (client *Client) WithRedirct(f func(*http.Request, []*http.Request) error) *Client

func (*Client) WithReqEncode

func (client *Client) WithReqEncode(f func(any) (io.Reader, string, error))

func (*Client) WithRespDecode

func (client *Client) WithRespDecode(f func(*http.Response, any) error)

func (*Client) WithTimeout

func (client *Client) WithTimeout(d time.Duration) *Client

func (*Client) WithTransport

func (client *Client) WithTransport(trans http.RoundTripper) *Client

type EgoSQL

type EgoSQL interface {
	SQLNames() []string
	SQLValues() []any
}

type Req

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

func (*Req) Do

func (req *Req) Do(bResp any) error

type SQLInsert

type SQLInsert interface {
	Fields(eg EgoSQL) SQLInsert
	Values(vs ...EgoSQL) SQLInsert
	Insert(dbxExec) error
	Clear()
	String() string
}

func InsertInto

func InsertInto(tablename string) SQLInsert

type SQLSelect

type SQLSelect interface {
	From(string) SQLSelect
	Join(string) SQLSelect
	On(string) SQLSelect
	Where(map[string]any) SQLSelect
	Limit(int) SQLSelect
	Offset(int) SQLSelect
	Group(string) SQLSelect
	Having(string) SQLSelect
	Order(string) SQLSelect
	Get(dbxGetSelect, any) error
	Select(dbxGetSelect, any) error
	Clear()
	String() string
}

func Select

func Select(es EgoSQL) SQLSelect

Jump to

Keyboard shortcuts

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