complone commented on code in PR #1855:
URL: https://github.com/apache/dubbo-go/pull/1855#discussion_r885192894
##########
config/rest_config.go:
##########
@@ -46,12 +59,94 @@ func (c *RestConsumerConfig) UnmarshalYAML(unmarshal
func(interface{}) error) er
return nil
}
+
+func (c *RestConsumerConfig) Init(rc *RootConfig) error {
+ restConsumerConfig := rc.RestConsumer
+
+ if restConsumerConfig == nil {
+ logger.Debugf("[rest-protocol] no consumer config")
+ return nil
+ }
+
+ restConsumerServiceConfigMap := make(map[string]*RestServiceConfig,
len(restConsumerConfig.RestServiceConfigsMap))
+ for key, rc := range restConsumerConfig.RestServiceConfigsMap {
+ rc.Client = common.GetNotEmptyStr(rc.Client,
restConsumerConfig.Client, constant.DefaultRestClient)
+ rc.RestMethodConfigs = initMethodConfigMap(rc,
restConsumerConfig.Consumes, restConsumerConfig.Produces)
+ restConsumerServiceConfigMap[key] = rc
+ }
+
+ SetRestConsumerServiceConfigMap(restConsumerServiceConfigMap)
+
+ return nil
+}
+
+// initProviderRestConfig ...
+func initMethodConfigMap(rc *RestServiceConfig, consumes string, produces
string) map[string]*RestMethodConfig {
+ mcm := make(map[string]*RestMethodConfig, len(rc.RestMethodConfigs))
+ for _, mc := range rc.RestMethodConfigs {
+ mc.InterfaceName = rc.InterfaceName
+ mc.Path = rc.Path + mc.Path
+ mc.Consumes = common.GetNotEmptyStr(mc.Consumes, rc.Consumes,
consumes)
+ mc.Produces = common.GetNotEmptyStr(mc.Produces, rc.Produces,
produces)
+ mc.MethodType = common.GetNotEmptyStr(mc.MethodType,
rc.MethodType)
+ mc = transformMethodConfig(mc)
+ mcm[mc.MethodName] = mc
+ }
+ return mcm
+}
+
+// transformMethodConfig
+func transformMethodConfig(methodConfig *RestMethodConfig) *RestMethodConfig {
Review Comment:
The return value cannot be deleted because RestServiceConfig needs to
declare the pointer type RestMethodConfigs map[string]*RestMethodConfig, and
the initMethodConfigMap method needs to obtain the converted config object
--
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]