Remove most of the checker warns
This commit is contained in:
parent
3067beb96c
commit
6aa2a94865
5 changed files with 10 additions and 12 deletions
|
@ -32,7 +32,7 @@ func (a *API) Login(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
w.Write([]byte(token))
|
||||
_, _ = w.Write([]byte(token))
|
||||
}
|
||||
|
||||
func (a *API) getUserFromToken(tokenStr string) (*model.User, error) {
|
||||
|
@ -71,9 +71,7 @@ func (a *API) Secured(fn func(http.ResponseWriter, *http.Request)) func(http.Res
|
|||
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(tokenStr, "Bearer ") {
|
||||
tokenStr = tokenStr[7:]
|
||||
}
|
||||
tokenStr = strings.TrimPrefix(tokenStr, "Bearer ")
|
||||
|
||||
user, err := a.getUserFromToken(tokenStr)
|
||||
if err != nil {
|
||||
|
|
|
@ -46,5 +46,5 @@ func JSON(w http.ResponseWriter, data interface{}, statusCode int) {
|
|||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(statusCode)
|
||||
w.Write(b)
|
||||
_, _ = w.Write(b)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue