Skip to content

Commit 67542f6

Browse files
committedApr 27, 2018
refactor None -> Skip
1 parent d8fbaef commit 67542f6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed
 

‎httpauth.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ func (c creds) Check(username, password string) bool {
3030
return ok && p == password
3131
}
3232

33-
// None is an implementation of Checker in which Check always returns true.
34-
type None struct{}
33+
// Skip is an implementation of Checker in which Check always returns true.
34+
var Skip Checker = skip{}
35+
36+
type skip struct{}
3537

3638
// Check implements Checker.
37-
func (n None) Check(username, password string) bool { return true }
39+
func (n skip) Check(username, password string) bool { return true }
3840

3941
// HandlerFunc returns an http.HandlerFunc which checks basic HTTP authentication header
4042
// values using Checker and passes requests to the given http.HandlerFunc when Check returns

‎httpauth_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ func TestCreds(t *testing.T) {
7272
}
7373

7474
func TestNone(t *testing.T) {
75-
n := None{}
76-
if !n.Check("", "") {
75+
if !Skip.Check("", "") {
7776
t.Errorf("n.Check(\"\", \"\") = false, expected: true")
7877
}
7978
}

0 commit comments

Comments
 (0)