...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package v2http
16
17 import (
18 "fmt"
19 "net/http"
20
21 "go.etcd.io/etcd/server/v3/etcdserver/api"
22 "go.etcd.io/etcd/server/v3/etcdserver/api/v2http/httptypes"
23 )
24
25 func authCapabilityHandler(fn func(http.ResponseWriter, *http.Request)) http.HandlerFunc {
26 return func(w http.ResponseWriter, r *http.Request) {
27 if !api.IsCapabilityEnabled(api.AuthCapability) {
28 notCapable(w, r, api.AuthCapability)
29 return
30 }
31 fn(w, r)
32 }
33 }
34
35 func notCapable(w http.ResponseWriter, r *http.Request, c api.Capability) {
36 herr := httptypes.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Not capable of accessing %s feature during rolling upgrades.", c))
37 if err := herr.WriteTo(w); err != nil {
38
39
40 }
41 }
42
View as plain text