AlexStocks commented on code in PR #3280:
URL: https://github.com/apache/dubbo-go/pull/3280#discussion_r2992587390


##########
protocol/triple/openapi/integration.go:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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 openapi
+
+import (
+       "net/http"
+       "sync"
+)
+
+import (
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3/common"
+       "dubbo.apache.org/dubbo-go/v3/global"
+)
+
+var (
+       globalService   *DefaultService
+       globalHandler   *RequestHandler
+       swaggerHandler  *SwaggerUIHandler
+       redocHandler    *RedocHandler
+       serviceInitOnce sync.Once
+)
+
+func InitService(cfg *global.OpenAPIConfig) {
+       serviceInitOnce.Do(func() {

Review Comment:
   [P1] 这里把 OpenAPI 服务做成了 `sync.Once` 全局单例,后续再启动第二个 triple server 
时,新配置不会生效。比如第一个 server 用 `/dubbo/openapi`,第二个 server 配 
`/custom/openapi`,`NewServer()` 会把 `/custom/openapi` 路由挂上去,但这里的 
`globalHandler/swaggerHandler/redocHandler` 仍然持有第一次初始化的 `cfg.Path`,第二个 server 
的请求会直接走到 404。建议把 OpenAPI service/handler 绑定到具体 `triple.Server` 
实例,或者至少在重复初始化时按新的配置刷新 handler。



-- 
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]

Reply via email to