Documentation ¶
Index ¶
- type Action
- type Config
- type Contexts
- func (c *Contexts) DecodeInto(to interface{}) error
- func (c *Contexts) NewContexts() *Contexts
- func (c *Contexts) NewHeader() http.Header
- func (c *Contexts) RespAutoError(err error)
- func (c *Contexts) RespBkEntity(data interface{})
- func (c *Contexts) RespBkError(errCode int, errMsg string)
- func (c *Contexts) RespCountInfoString(count int64, infoArray []string)
- func (c *Contexts) RespEntity(data interface{})
- func (c *Contexts) RespEntityWithCount(count int64, info interface{})
- func (c *Contexts) RespEntityWithError(data interface{}, err error)
- func (c *Contexts) RespErrorCodeF(errCode int, logMsg string, errorf ...interface{})
- func (c *Contexts) RespErrorCodeOnly(errCode int, format string, args ...interface{})
- func (c *Contexts) RespString(data string)
- func (c *Contexts) RespStringArray(jsonArray []string)
- func (c *Contexts) RespWithError(err error, errCode int, format string, args ...interface{})
- func (c *Contexts) WithStatusCode(statusCode int) *Contexts
- type CountInfo
- type Kit
- type RestUtility
- type RestfulConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Contexts ¶
type Contexts struct { Kit *Kit Request *restful.Request // contains filtered or unexported fields }
func (*Contexts) DecodeInto ¶
func (*Contexts) NewContexts ¶
NewContexts 产生一个新的contexts, 一般用于在创建新的协程的时候,这个时候会对header 做处理,删除不必要的http header。
func (*Contexts) NewHeader ¶
NewHeader 产生一个新的header, 一般用于在创建新的协程的时候,这个时候会对header 做处理,删除不必要的http header。
func (*Contexts) RespAutoError ¶
func (*Contexts) RespBkEntity ¶
func (c *Contexts) RespBkEntity(data interface{})
func (*Contexts) RespBkError ¶
func (*Contexts) RespCountInfoString ¶
func (*Contexts) RespEntity ¶
func (c *Contexts) RespEntity(data interface{})
func (*Contexts) RespEntityWithCount ¶
func (*Contexts) RespEntityWithError ¶
func (*Contexts) RespErrorCodeF ¶
WriteErrorf used to write a error response to the request client. it will wrapper the error with error code and other errorf args. errorf is used to format multiple-language error message. it will also will log the error at the same time with logMsg.
func (*Contexts) RespErrorCodeOnly ¶
func (*Contexts) RespString ¶
RespString response the data format to a json string. the data is a string, and do not need marshal, can return directly.
func (*Contexts) RespStringArray ¶
RespString response the data format to a json string. the data is a string, and do not need marshal, can return directly.
func (*Contexts) RespWithError ¶
WriteError is used to write a error response to the http client, which means the request occur an error. It receive an err and an optional error code parameter. It will testify the err, if the err is a CCErrorCoder, then the error code inside it will be used. Otherwise, if errCode is set and > 0, then errCode value is used. Finally, if error code is not set and err is not CCErrorCoder, then it will be set with a default CCSystemBusy code. This function will also write a log when it's called which contains the request id field.
func (*Contexts) WithStatusCode ¶
type CountInfo ¶
type CountInfo struct { Count int64 `json:"count"` Info interface{} `json:"info"` }
type Kit ¶
type Kit struct { Rid string Header http.Header Ctx context.Context CCError errors.DefaultCCErrorIf User string SupplierAccount string }
type RestUtility ¶
type RestUtility struct { Config // contains filtered or unexported fields }
func NewRestUtility ¶
func NewRestUtility(conf Config) *RestUtility
func (*RestUtility) AddHandler ¶
func (r *RestUtility) AddHandler(action Action)
func (*RestUtility) AddToRestfulWebService ¶
func (r *RestUtility) AddToRestfulWebService(ws *restful.WebService)
type RestfulConfig ¶
type RestfulConfig struct {
RootPath string
}