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

replace id to path

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