mirror of
https://github.com/therootcompany/golib.git
synced 2026-03-13 12:27:59 +00:00
fix(auth): update test
This commit is contained in:
parent
92f865912a
commit
8842791e34
@ -20,8 +20,7 @@ func (exampleCredentialStore) Authenticate(username, password string) (auth.Basi
|
||||
// Set the WWW-Authenticate header before writing a 401 to instruct the browser
|
||||
// to prompt for Username and Password on failure.
|
||||
func ExampleBasicRequestAuthenticator() {
|
||||
ra := auth.NewBasicRequestAuthenticator()
|
||||
ra.Authenticator = exampleCredentialStore{} // swap in your real credential store
|
||||
ra := auth.NewBasicRequestAuthenticator(exampleCredentialStore{})
|
||||
|
||||
http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {
|
||||
principle, err := ra.Authenticate(r)
|
||||
@ -30,6 +29,6 @@ func ExampleBasicRequestAuthenticator() {
|
||||
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(w, "hello %s", principle.ID())
|
||||
_, _ = fmt.Fprintf(w, "hello %s", principle.ID())
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user