test
This commit is contained in:
@@ -37,6 +37,7 @@ func RegisterUser(c *gin.Context) {
|
||||
globals.SugarLogger.Debugf("End API :%s error:%v:", c.Request.URL, err)
|
||||
return
|
||||
}
|
||||
globals.SugarLogger.Debugf("Begin API :%s params: %v ip: %s", c.Request.URL, utils.Format4Output(user, true))
|
||||
if !captchaVerify(c, user.Code) {
|
||||
c.JSON(http.StatusOK, &CallBack{
|
||||
Code: model.ErrCodeNormal,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/jx-print/globals"
|
||||
"git.rosy.net.cn/jx-print/model"
|
||||
"github.com/dchest/captcha"
|
||||
@@ -166,3 +167,27 @@ func BuildErr(errs []error) (err error) {
|
||||
}
|
||||
return fmt.Errorf(errStr.String())
|
||||
}
|
||||
|
||||
func Format4Output(obj interface{}, isSingleLine bool) (retVal string) {
|
||||
retVal, ok := obj.(string)
|
||||
if !ok {
|
||||
var (
|
||||
result []byte
|
||||
err error
|
||||
)
|
||||
if isSingleLine {
|
||||
if result, err = json.Marshal(obj); err == nil {
|
||||
retVal = string(result)
|
||||
}
|
||||
} else {
|
||||
if result, err = json.MarshalIndent(obj, "", "\t"); err == nil {
|
||||
retVal = string(result)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Infof("Format4Output Marshal:%v failed with error:%v", obj, err)
|
||||
retVal = fmt.Sprintf("%v", obj)
|
||||
}
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user