MCPcopy
hub / github.com/cubefs/cubefs / handlerWithInterceptor

Method handlerWithInterceptor

authnode/http_server.go:126–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

124}
125
126func (m *Server) handlerWithInterceptor() http.Handler {
127 return http.HandlerFunc(
128 func(w http.ResponseWriter, r *http.Request) {
129 if m.partition.IsRaftLeader() {
130 if m.metaReady {
131 m.ServeHTTP(w, r)
132 return
133 }
134 log.LogWarnf("action[handlerWithInterceptor] leader meta has not ready")
135 http.Error(w, m.leaderInfo.addr, http.StatusBadRequest)
136 return
137 }
138 if m.leaderInfo.addr == "" {
139 log.LogErrorf("action[handlerWithInterceptor] no leader,request[%v]", r.URL)
140 http.Error(w, "no leader", http.StatusBadRequest)
141 return
142 }
143 m.proxy(w, r)
144 })
145}
146
147func (m *Server) proxy(w http.ResponseWriter, r *http.Request) {
148 if m.cluster.PKIKey.EnableHTTPS {

Callers 1

handleFunctionsMethod · 0.95

Calls 6

ServeHTTPMethod · 0.95
proxyMethod · 0.95
LogWarnfFunction · 0.92
LogErrorfFunction · 0.92
IsRaftLeaderMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected