applying go fmt

This commit is contained in:
Roland Osborne 2022-07-26 22:45:38 -07:00
parent 97f7239be1
commit ffb0d1b8a5
4 changed files with 12 additions and 14 deletions

View File

@ -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 {

View File

@ -64,4 +64,3 @@ func ParseRequest(r *http.Request, w http.ResponseWriter, obj interface{}) error
dec.DisallowUnknownFields()
return dec.Decode(&obj)
}

View File

@ -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

View File

@ -445,4 +445,3 @@ type TopicDetail struct {
Transform string `json:"transform,omitempty"`
}