mirror of https://github.com/docker/docs.git
Tiny refactor
It is a little wired to use "err.ServeHTTP". Via the sample from docker/distribution, we can use "challenge" as the variable name here. Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
parent
7be7b6beb5
commit
39c3f46006
|
@ -64,8 +64,10 @@ func (root *rootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
var authCtx context.Context
|
||||
var err error
|
||||
if authCtx, err = root.auth.Authorized(ctx, access...); err != nil {
|
||||
if err, ok := err.(auth.Challenge); ok {
|
||||
err.ServeHTTP(w, r)
|
||||
if challenge, ok := err.(auth.Challenge); ok {
|
||||
// Let the challenge write the response.
|
||||
challenge.ServeHTTP(w, r)
|
||||
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue