AlexStocks commented on code in PR #3213: URL: https://github.com/apache/dubbo-go/pull/3213#discussion_r2899089927
########## metrics/probe/http.go: ########## @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package probe + +import ( + "errors" + "net/http" +) + +var ( + errNotReady = errors.New("not ready") + errNotStarted = errors.New("not started") +) + +func livenessHandler(w http.ResponseWriter, r *http.Request) { + if err := CheckLiveness(r.Context()); err != nil { Review Comment: 三个 handler 均未限制 HTTP 方法。Kubernetes 探针只发 GET,但 `POST /ready`、`DELETE /startup` 等请求也会触发健康检查逻辑并返回 200/503,不符合最小权限原则和 Kubernetes 规范。 建议在每个 handler 开头加: ```go if r.Method \!= http.MethodGet { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) return } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
