You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/11/11 10:53:32 UTC

[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #854: Impl: support extension of two urls comparison.

AlexStocks commented on a change in pull request #854:
URL: https://github.com/apache/dubbo-go/pull/854#discussion_r521275019



##########
File path: common/url_tool_extension.go
##########
@@ -0,0 +1,46 @@
+/*
+ * 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 common
+
+var urlComparator URLComparator
+
+// Define some func for URL, such as comparison of URL.
+// Your can define your own implements, and invoke SetURLComparator.
+type URLComparator interface {
+	CompareURLEqual(*URL, *URL, ...string) bool
+}
+
+func SetURLComparator(comparator URLComparator) {
+	urlComparator = comparator
+}
+func GetURLComparator() URLComparator {
+	return urlComparator
+}
+
+// Config default defaultURLComparator.
+func init() {
+	SetURLComparator(defaultURLComparator{})
+}
+
+type defaultURLComparator struct {
+}
+
+// default comparison implements
+func (defaultURLComparator) CompareURLEqual(l *URL, r *URL, excludeParam ...string) bool {
+	return IsEquals(*l, *r, excludeParam...)

Review comment:
       @flycash 我们需要一个更系统性的 URL 改进方案,必须加锁确保安全,然后至少添加一个 Copy 函数,目前的实现很容易被人误用。




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org