Skip to content
Snippets Groups Projects
Commit c3db25d7 authored by Patrick's avatar Patrick
Browse files

replace id to path

parent 02c853e7
Branches
Tags
No related merge requests found
......@@ -62,7 +62,7 @@ func (cr *RestConfigReader) ReadConsumerConfig(reader *bytes.Buffer) error {
for key, rc := range restConsumerConfig.RestServiceConfigsMap {
rc.Client = getNotEmptyStr(rc.Client, restConsumerConfig.Client, constant.DEFAULT_REST_CLIENT)
rc.RestMethodConfigsMap = initMethodConfigMap(rc, restConsumerConfig.Consumes, restConsumerConfig.Produces)
restConsumerServiceConfigMap[strings.TrimPrefix(key, "/")] = rc
restConsumerServiceConfigMap[key] = rc
}
config.SetRestConsumerServiceConfigMap(restConsumerServiceConfigMap)
return nil
......@@ -79,7 +79,7 @@ func (cr *RestConfigReader) ReadProviderConfig(reader *bytes.Buffer) error {
for key, rc := range restProviderConfig.RestServiceConfigsMap {
rc.Server = getNotEmptyStr(rc.Server, restProviderConfig.Server, constant.DEFAULT_REST_SERVER)
rc.RestMethodConfigsMap = initMethodConfigMap(rc, restProviderConfig.Consumes, restProviderConfig.Produces)
restProviderServiceConfigMap[strings.TrimPrefix(key, "/")] = rc
restProviderServiceConfigMap[key] = rc
}
config.SetRestProviderServiceConfigMap(restProviderServiceConfigMap)
return nil
......
......@@ -123,13 +123,13 @@ func (c *RestMethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) erro
}
// nolint
func GetRestConsumerServiceConfig(path string) *RestServiceConfig {
return restConsumerServiceConfigMap[path]
func GetRestConsumerServiceConfig(id string) *RestServiceConfig {
return restConsumerServiceConfigMap[id]
}
// nolint
func GetRestProviderServiceConfig(path string) *RestServiceConfig {
return restProviderServiceConfigMap[path]
func GetRestProviderServiceConfig(id string) *RestServiceConfig {
return restProviderServiceConfigMap[id]
}
// nolint
......
......@@ -18,7 +18,6 @@
package rest
import (
"strings"
"sync"
"time"
)
......@@ -72,7 +71,8 @@ func (rp *RestProtocol) Export(invoker protocol.Invoker) protocol.Exporter {
url := invoker.GetUrl()
serviceKey := url.ServiceKey()
exporter := NewRestExporter(serviceKey, invoker, rp.ExporterMap())
restServiceConfig := rest_config.GetRestProviderServiceConfig(strings.TrimPrefix(url.Path, "/"))
id := url.GetParam(constant.BEAN_NAME_KEY, "")
restServiceConfig := rest_config.GetRestProviderServiceConfig(id)
if restServiceConfig == nil {
logger.Errorf("%s service doesn't has provider config", url.Path)
return nil
......@@ -94,7 +94,8 @@ func (rp *RestProtocol) Refer(url *common.URL) protocol.Invoker {
if t, err := time.ParseDuration(requestTimeoutStr); err == nil {
requestTimeout = t
}
restServiceConfig := rest_config.GetRestConsumerServiceConfig(strings.TrimPrefix(url.Path, "/"))
id := url.GetParam(constant.BEAN_NAME_KEY, "")
restServiceConfig := rest_config.GetRestConsumerServiceConfig(id)
if restServiceConfig == nil {
logger.Errorf("%s service doesn't has consumer config", url.Path)
return nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment