1
0
mirror of https://github.com/labstack/echo.git synced 2025-11-29 22:48:07 +02:00

[FIX] Cleanup code (#1061)

Code cleanup
This commit is contained in:
Evgeniy Kulikov
2018-02-21 21:44:17 +03:00
committed by Vishal Rana
parent 90d675fa2a
commit f49d166e6f
19 changed files with 141 additions and 65 deletions

View File

@@ -114,14 +114,14 @@ func keyFromHeader(header string, authScheme string) keyExtractor {
return func(c echo.Context) (string, error) {
auth := c.Request().Header.Get(header)
if auth == "" {
return "", errors.New("Missing key in request header")
return "", errors.New("missing key in request header")
}
if header == echo.HeaderAuthorization {
l := len(authScheme)
if len(auth) > l+1 && auth[:l] == authScheme {
return auth[l+1:], nil
}
return "", errors.New("Invalid key in the request header")
return "", errors.New("invalid key in the request header")
}
return auth, nil
}
@@ -132,7 +132,7 @@ func keyFromQuery(param string) keyExtractor {
return func(c echo.Context) (string, error) {
key := c.QueryParam(param)
if key == "" {
return "", errors.New("Missing key in the query string")
return "", errors.New("missing key in the query string")
}
return key, nil
}
@@ -143,7 +143,7 @@ func keyFromForm(param string) keyExtractor {
return func(c echo.Context) (string, error) {
key := c.FormValue(param)
if key == "" {
return "", errors.New("Missing key in the form")
return "", errors.New("missing key in the form")
}
return key, nil
}