update allowed func to return error instead of bool

this allows returning a more accurate error message, particularly in the
case of an invalid referer header
This commit is contained in:
Will Norris 2015-12-13 16:59:56 -08:00
parent 710a2ab1c9
commit 27d53782b4
2 changed files with 17 additions and 24 deletions

View file

@ -70,7 +70,7 @@ func TestAllowed(t *testing.T) {
t.Errorf("error parsing url %q: %v", tt.url, err)
}
req := &Request{u, tt.options, tt.request}
if got, want := p.allowed(req), tt.allowed; got != want {
if got, want := p.allowed(req), tt.allowed; (got == nil) != want {
t.Errorf("allowed(%q) returned %v, want %v.\nTest struct: %#v", req, got, want, tt)
}
}