service

package
v0.0.0-...-0e6d7d3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveRequests

func ActiveRequests() int

func FromHandlerFunc

func FromHandlerFunc(f http.HandlerFunc) http.HandlerFunc

func FromMethod

func FromMethod(method Method, decorators ...Decorator) http.HandlerFunc

func FromMethodRaw

func FromMethodRaw(f func(*Meta, http.ResponseWriter)) http.HandlerFunc

func RegisterHandler

func RegisterHandler(router *mux.Router, path string, f http.HandlerFunc)

原生回调,用于第三方平台与服务器的回调

func RegisterMethod

func RegisterMethod(router *mux.Router, path string, method Method, decorators ...Decorator)

authentication: 是否需要登录

func RegisterMethodRaw

func RegisterMethodRaw(router *mux.Router, path string, f func(*Meta, http.ResponseWriter))

半原生回调,用于第三方平台与服务器的表单回调, 不适用body格式的请求(比如XML)

func WaitQuiescent

func WaitQuiescent(timeout time.Duration) error

Types

type Decorator

type Decorator func(*Meta) error

type Error

type Error struct {
	Code        int
	Description string
	Data        interface{}
}

func NewError

func NewError(code int, desc string, data ...interface{}) *Error

func (*Error) Error

func (this *Error) Error() string

type ErrorHandler

type ErrorHandler struct {
}

func (*ErrorHandler) Handle

func (h *ErrorHandler) Handle(ctx context.Context, err error)

type Fail

type Fail struct {
	Ok          bool        `json:"ok"`
	ErrorCode   int         `json:"error_code"`
	Description string      `json:"description"`
	Data        interface{} `json:"data,omitempty"`
}

func (*Fail) Error

func (f *Fail) Error() string

type Meta

type Meta struct {
	UserId int64
	Token  string
	IP     string

	Request *http.Request
	// contains filtered or unexported fields
}

func MergeForm

func MergeForm(r *http.Request) *Meta

func NewMeta

func NewMeta(r *http.Request) *Meta

func (*Meta) APStr

func (this *Meta) APStr() string

func (*Meta) Get

func (this *Meta) Get(key string) Result

func (*Meta) JsonForm

func (this *Meta) JsonForm() map[string]interface{}

func (*Meta) Language

func (this *Meta) Language() string

返回语言代码 zh/en/hant

func (*Meta) Log

func (this *Meta) Log()

func (*Meta) LogRaw

func (this *Meta) LogRaw()

func (*Meta) Took

func (this *Meta) Took() time.Duration

type Method

type Method func(*Meta) (interface{}, error)

type Result

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

func (Result) Bool

func (this Result) Bool() bool

func (Result) Date

func (this Result) Date() *time.Time

func (Result) Exists

func (this Result) Exists() bool

func (Result) Float64

func (this Result) Float64() float64

func (Result) Int

func (this Result) Int() int

func (Result) Int32

func (this Result) Int32() int32

func (Result) Int64

func (this Result) Int64() int64

func (Result) Int64s

func (this Result) Int64s() []int64

func (Result) Ints

func (this Result) Ints() []int

func (Result) Json

func (this Result) Json() gjson.Result

func (Result) String

func (this Result) String() string

func (Result) Strings

func (this Result) Strings() []string

func (Result) Unmarshal

func (this Result) Unmarshal(v interface{}) error

type Success

type Success struct {
	Ok     bool        `json:"ok"`
	Result interface{} `json:"result"`
}

Jump to

Keyboard shortcuts

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