earaujoassis / space

Compare 8aebf54 ... +0 ... 1b94df7

Showing 1 of 4 files from the diff.

@@ -15,7 +15,21 @@
Loading
15 15
// BasicAuthDecode decodes a key-secret pair from a token string, originally used in a
16 16
//      HTTP Basic Authentication strategy (HTTP Request Header)
17 17
func BasicAuthDecode(token string) (string, string) {
18 -
    bytes, _ := base64.StdEncoding.DecodeString(token)
18 +
    bytes, err := base64.StdEncoding.DecodeString(token)
19 +
    if err != nil {
20 +
        return "", ""
21 +
    }
19 22
    values := strings.Split(string(bytes), ":")
23 +
    if len(values) < 2 {
24 +
        return "", ""
25 +
    }
20 26
    return values[0], values[1]
21 27
}
28 +
29 +
// MustServeJSON determines if the HTTP response must be a JSON content or not
30 +
//      using the HTTP request path and the request header attribute `Accept`
31 +
func MustServeJSON(path string, accept string) bool {
32 +
    return strings.HasPrefix(path, "/api") ||
33 +
        strings.HasPrefix(path, "/token") ||
34 +
        strings.HasPrefix(path, "/oauth/token")
35 +
}

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
Project Totals (18 files) 14.29%
Loading