Skip to content

Commit 3344c72

Browse files
Remove the bool from ValidRequest
1 parent 147c3c0 commit 3344c72

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

signature/signature.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ func (v *Validator) ValidSignature(ts, rqp string, b []byte, rs string) bool {
108108
// incoming requests
109109
// To use just pass the request:
110110
// signature.Validate(request)
111-
func (v *Validator) ValidRequest(r *http.Request) (bool, error) {
111+
func (v *Validator) ValidRequest(r *http.Request) error {
112112
ts := r.Header.Get(tsHeader)
113113
rs := r.Header.Get(sHeader)
114114
if ts == "" || rs == "" {
115-
return false, fmt.Errorf("Unknown host: %s", r.Host)
115+
return fmt.Errorf("Unknown host: %s", r.Host)
116116
}
117117
b, _ := ioutil.ReadAll(r.Body)
118118
if v.ValidTimestamp(ts) == false || v.ValidSignature(ts, r.URL.RawQuery, b, rs) == false {
119-
return false, fmt.Errorf("Unknown host: %s", r.Host)
119+
return fmt.Errorf("Unknown host: %s", r.Host)
120120
}
121121
r.Body = ioutil.NopCloser(bytes.NewBuffer(b))
122-
return true, nil
122+
return nil
123123
}
124124

125125
// Validate is a handler wrapper that takes care of the signature validation of
@@ -129,7 +129,7 @@ func (v *Validator) ValidRequest(r *http.Request) (bool, error) {
129129
// http.Handle("/path", signature.Validate(handleThing))
130130
func (v *Validator) Validate(h http.Handler) http.Handler {
131131
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
132-
if res, _ := v.ValidRequest(r); res == false {
132+
if err := v.ValidRequest(r); err != nil {
133133
http.Error(w, "", http.StatusUnauthorized)
134134
return
135135
}

0 commit comments

Comments
 (0)