-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy patherror.go
72 lines (58 loc) · 1.51 KB
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package vangoh
import (
"fmt"
"net/http"
)
type AuthenticationError struct {
c int
s string
}
func (a *AuthenticationError) Error() string {
return a.s
}
func (a *AuthenticationError) StatusCode() int {
return a.c
}
func (a *AuthenticationError) WriteResponse(w http.ResponseWriter, debug bool) {
w.WriteHeader(a.StatusCode())
if debug {
w.Header().Add("Content-Type", "text/plain")
fmt.Fprintf(w, "%s", a)
}
}
var ErrorAuthHeaderMissing = &AuthenticationError{
c: http.StatusBadRequest,
s: "Missing 'Authorization' header",
}
var ErrorAuthHeaderMalformed = &AuthenticationError{
c: http.StatusBadRequest,
s: "Authorization header does not match expected format",
}
var ErrorDateHeaderMissing = &AuthenticationError{
c: http.StatusBadRequest,
s: "Missing 'Date' header",
}
var ErrorDateHeaderMalformed = &AuthenticationError{
c: http.StatusBadRequest,
s: "Date header is not a valid format",
}
var ErrorDateHeaderTooSkewed = &AuthenticationError{
c: http.StatusForbidden,
s: "Date header's value is too old",
}
var ErrorAuthOrgUnknown = &AuthenticationError{
c: http.StatusBadRequest,
s: "Authentication organization is not recognized",
}
var ErrorInProviderKeyLookup = &AuthenticationError{
c: http.StatusInternalServerError,
s: "Unable to look up secret key",
}
var ErrorSecretNotFound = &AuthenticationError{
c: http.StatusForbidden,
s: "Authentication key is not recognized",
}
var ErrorHMACSignatureMismatch = &AuthenticationError{
c: http.StatusForbidden,
s: "HMAC signature does not match",
}