()
| 124 | } |
| 125 | |
| 126 | func (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 | |
| 147 | func (m *Server) proxy(w http.ResponseWriter, r *http.Request) { |
| 148 | if m.cluster.PKIKey.EnableHTTPS { |
no test coverage detected