mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
applying go fmt
This commit is contained in:
parent
97f7239be1
commit
ffb0d1b8a5
@ -111,14 +111,14 @@ func ParamAgentToken(r *http.Request, detail bool) (*store.Account, int, error)
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, http.StatusNotFound, err
|
||||
}
|
||||
return nil, http.StatusInternalServerError, err
|
||||
return nil, http.StatusInternalServerError, err
|
||||
}
|
||||
} else {
|
||||
if err := store.DB.Preload("Account").Where("account_id = ? AND token = ?", target, access).First(&app).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, http.StatusNotFound, err
|
||||
}
|
||||
return nil, http.StatusInternalServerError, err
|
||||
return nil, http.StatusInternalServerError, err
|
||||
}
|
||||
}
|
||||
if app.Account.Disabled {
|
||||
@ -128,7 +128,7 @@ func ParamAgentToken(r *http.Request, detail bool) (*store.Account, int, error)
|
||||
return &app.Account, http.StatusOK, nil
|
||||
}
|
||||
|
||||
//BearerAppToken retrieves account specified by authorization header
|
||||
//BearerAppToken retrieves account specified by authorization header
|
||||
func BearerAppToken(r *http.Request, detail bool) (*store.Account, int, error) {
|
||||
|
||||
// parse bearer authentication
|
||||
@ -146,14 +146,14 @@ func BearerAppToken(r *http.Request, detail bool) (*store.Account, int, error) {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, http.StatusNotFound, err
|
||||
}
|
||||
return nil, http.StatusInternalServerError, err
|
||||
return nil, http.StatusInternalServerError, err
|
||||
}
|
||||
} else {
|
||||
if err := store.DB.Preload("Account").Where("account_id = ? AND token = ?", target, access).First(&app).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, http.StatusNotFound, err
|
||||
}
|
||||
return nil, http.StatusInternalServerError, err
|
||||
return nil, http.StatusInternalServerError, err
|
||||
}
|
||||
}
|
||||
if app.Account.Disabled {
|
||||
@ -209,14 +209,14 @@ func ParamContactToken(r *http.Request, detail bool) (*store.Card, int, error) {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, http.StatusNotFound, err
|
||||
}
|
||||
return nil, http.StatusInternalServerError, err
|
||||
return nil, http.StatusInternalServerError, err
|
||||
}
|
||||
} else {
|
||||
if err := store.DB.Preload("CardSlot").Preload("Account").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, http.StatusNotFound, err
|
||||
}
|
||||
return nil, http.StatusInternalServerError, err
|
||||
return nil, http.StatusInternalServerError, err
|
||||
}
|
||||
}
|
||||
if card.Account.Disabled {
|
||||
@ -247,14 +247,14 @@ func BearerContactToken(r *http.Request, detail bool) (*store.Card, int, error)
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, http.StatusNotFound, err
|
||||
}
|
||||
return nil, http.StatusInternalServerError, err
|
||||
return nil, http.StatusInternalServerError, err
|
||||
}
|
||||
} else {
|
||||
if err := store.DB.Preload("Account").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, http.StatusNotFound, err
|
||||
}
|
||||
return nil, http.StatusInternalServerError, err
|
||||
return nil, http.StatusInternalServerError, err
|
||||
}
|
||||
}
|
||||
if card.Account.Disabled {
|
||||
|
@ -64,4 +64,3 @@ func ParseRequest(r *http.Request, w http.ResponseWriter, obj interface{}) error
|
||||
dec.DisallowUnknownFields()
|
||||
return dec.Decode(&obj)
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,9 @@ func ErrMsg(err error) {
|
||||
|
||||
//LogMsg prints detailed error string
|
||||
func LogMsg(msg string) {
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
p, _ := os.Getwd()
|
||||
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, msg)
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
p, _ := os.Getwd()
|
||||
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, msg)
|
||||
}
|
||||
|
||||
//PrintMsg prints debug message
|
||||
|
@ -445,4 +445,3 @@ type TopicDetail struct {
|
||||
|
||||
Transform string `json:"transform,omitempty"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user