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/07/29 07:53:28 UTC

[GitHub] [dubbo-go] benbochong opened a new pull request #677: rest协议支持单url的get、post、put、patch方法

benbochong opened a new pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677


   <!--  Thanks for sending a pull request! 
   -->
   
   **What this PR does**:
   
   **Which issue(s) this PR fixes**:
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
   -->
   Fixes #
   
   **Special notes for your reviewer**:
   
   **Does this PR introduce a user-facing change?**:
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
   -->
   ```release-note
   
   ```


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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #677: Ftr: support get/post/put/patch in rest protocol

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677#discussion_r462229611



##########
File path: protocol/rest/config/reader/rest_config_reader.go
##########
@@ -90,7 +90,7 @@ func initMethodConfigMap(rc *config.RestServiceConfig, consumes string, produces
 	mcm := make(map[string]*config.RestMethodConfig, len(rc.RestMethodConfigs))
 	for _, mc := range rc.RestMethodConfigs {
 		mc.InterfaceName = rc.InterfaceName
-		mc.Path = rc.Path + mc.Path
+		//mc.Path = rc.Path + mc.Path

Review comment:
       delete it if u think it is of no usage.

##########
File path: protocol/rest/rest_protocol.go
##########
@@ -75,9 +75,10 @@ func (rp *RestProtocol) Export(invoker protocol.Invoker) protocol.Exporter {
 	}
 	rp.SetExporterMap(serviceKey, exporter)
 	restServer := rp.getServer(url, restServiceConfig.Server)
-	for _, methodConfig := range restServiceConfig.RestMethodConfigsMap {
+	/*for _, methodConfig := range restServiceConfig.RestMethodConfigsMap {
 		restServer.Deploy(methodConfig, server.GetRouteFunc(invoker, methodConfig))
-	}
+	}*/

Review comment:
       the same as above.




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


[GitHub] [dubbo-go] zouyx commented on a change in pull request #677: Ftr: support get/post/put/patch in rest protocol

Posted by GitBox <gi...@apache.org>.
zouyx commented on a change in pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677#discussion_r462701968



##########
File path: protocol/rest/server/server_impl/go_restful_server.go
##########
@@ -82,23 +83,39 @@ func (grs *GoRestfulServer) Start(url common.URL) {
 
 // Publish a http api in go-restful server
 // The routeFunc should be invoked when the server receive a request
-func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) {
-	ws := &restful.WebService{}
+func (grs *GoRestfulServer) Deploy(restServiceConfig *config.RestServiceConfig, invoker protocol.Invoker) {
+	/*ws := &restful.WebService{}

Review comment:
       Delete it if useless




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


[GitHub] [dubbo-go] benbochong commented on a change in pull request #677: Ftr: support get/post/put/patch in rest protocol

Posted by GitBox <gi...@apache.org>.
benbochong commented on a change in pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677#discussion_r462858369



##########
File path: protocol/rest/server/server_impl/go_restful_server.go
##########
@@ -82,23 +83,39 @@ func (grs *GoRestfulServer) Start(url common.URL) {
 
 // Publish a http api in go-restful server
 // The routeFunc should be invoked when the server receive a request
-func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) {
-	ws := &restful.WebService{}
+func (grs *GoRestfulServer) Deploy(restServiceConfig *config.RestServiceConfig, invoker protocol.Invoker) {
+	/*ws := &restful.WebService{}
 	rf := func(req *restful.Request, resp *restful.Response) {
 		routeFunc(NewGoRestfulRequestAdapter(req), resp)
 	}
 	ws.Path(restMethodConfig.Path).
 		Produces(strings.Split(restMethodConfig.Produces, ",")...).
 		Consumes(strings.Split(restMethodConfig.Consumes, ",")...).
 		Route(ws.Method(restMethodConfig.MethodType).To(rf))
-	grs.container.Add(ws)
+	grs.container.Add(ws)*/
 
+	ws := &restful.WebService{}
+	ws.Path(restServiceConfig.Path)

Review comment:
       You don't have to set the root path. The following configurations are completely equivalent.
   
   ```
   services:
     "CourseProvider":
       registry: "etcd"
       protocol : "rest"
       interface : "com.llll.Course"
       loadbalance: "random"
       warmup: "100"
       cluster: "failover"
       rest_path: "/courses"
       rest_produces: "application/json;charset=utf-8"
       rest_consumes: "application/json;charset=utf-8,*/*"
       methods:
       - name: "ViewList"
         rest_path: "/"
         rest_method: "GET"
       - name: "ViewOne"
         rest_path: "/{id}"
         rest_path_params: "0:id"
         rest_method: "GET"
       - name: "CreateDoc"
         rest_path: "/"
         rest_body: 0
         rest_method: "POST"
       - name: "EditDoc"
         rest_path: "/{id}"
         rest_path_params: "0:id"
         rest_body: 1
         rest_method: "POST"
   ```
   
   ```
   services:
     "CourseProvider":
       registry: "etcd"
       protocol : "rest"
       interface : "com.llll.Course"
       loadbalance: "random"
       warmup: "100"
       cluster: "failover"
       rest_produces: "application/json;charset=utf-8"
       rest_consumes: "application/json;charset=utf-8,*/*"
       methods:
       - name: "ViewList"
         rest_path: "/courses"
         rest_method: "GET"
       - name: "ViewOne"
         rest_path: "/courses/{id}"
         rest_path_params: "0:id"
         rest_method: "GET"
       - name: "CreateDoc"
         rest_path: "/courses"
         rest_body: 0
         rest_method: "POST"
       - name: "EditDoc"
         rest_path: "/courses/{id}"
         rest_path_params: "0:id"
         rest_body: 1
         rest_method: "POST"
   ```




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


[GitHub] [dubbo-go] benbochong commented on a change in pull request #677: Ftr: support get/post/put/patch in rest protocol

Posted by GitBox <gi...@apache.org>.
benbochong commented on a change in pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677#discussion_r462864504



##########
File path: protocol/rest/server/server_impl/go_restful_server.go
##########
@@ -82,23 +83,39 @@ func (grs *GoRestfulServer) Start(url common.URL) {
 
 // Publish a http api in go-restful server
 // The routeFunc should be invoked when the server receive a request
-func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) {
-	ws := &restful.WebService{}
+func (grs *GoRestfulServer) Deploy(restServiceConfig *config.RestServiceConfig, invoker protocol.Invoker) {
+	/*ws := &restful.WebService{}
 	rf := func(req *restful.Request, resp *restful.Response) {
 		routeFunc(NewGoRestfulRequestAdapter(req), resp)
 	}
 	ws.Path(restMethodConfig.Path).
 		Produces(strings.Split(restMethodConfig.Produces, ",")...).
 		Consumes(strings.Split(restMethodConfig.Consumes, ",")...).
 		Route(ws.Method(restMethodConfig.MethodType).To(rf))
-	grs.container.Add(ws)
+	grs.container.Add(ws)*/
 
+	ws := &restful.WebService{}
+	ws.Path(restServiceConfig.Path)

Review comment:
       Restful protocol specifies architecture constraints and principles. Usually, a service corresponds to a resource,the rootpath is the resource name. 




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


[GitHub] [dubbo-go] Patrick0308 commented on a change in pull request #677: Ftr: support get/post/put/patch in rest protocol

Posted by GitBox <gi...@apache.org>.
Patrick0308 commented on a change in pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677#discussion_r462744403



##########
File path: protocol/rest/server/server_impl/go_restful_server.go
##########
@@ -82,23 +83,39 @@ func (grs *GoRestfulServer) Start(url common.URL) {
 
 // Publish a http api in go-restful server
 // The routeFunc should be invoked when the server receive a request
-func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) {
-	ws := &restful.WebService{}
+func (grs *GoRestfulServer) Deploy(restServiceConfig *config.RestServiceConfig, invoker protocol.Invoker) {
+	/*ws := &restful.WebService{}
 	rf := func(req *restful.Request, resp *restful.Response) {
 		routeFunc(NewGoRestfulRequestAdapter(req), resp)
 	}
 	ws.Path(restMethodConfig.Path).
 		Produces(strings.Split(restMethodConfig.Produces, ",")...).
 		Consumes(strings.Split(restMethodConfig.Consumes, ",")...).
 		Route(ws.Method(restMethodConfig.MethodType).To(rf))
-	grs.container.Add(ws)
+	grs.container.Add(ws)*/
 
+	ws := &restful.WebService{}
+	ws.Path(restServiceConfig.Path)

Review comment:
       At first, we can't ask user must set server path config. And we should let user more flexible to config path, like spring mvc.
   




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


[GitHub] [dubbo-go] Patrick0308 closed pull request #677: Ftr: support get/post/put/patch in rest protocol

Posted by GitBox <gi...@apache.org>.
Patrick0308 closed pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677


   


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


[GitHub] [dubbo-go] benbochong commented on a change in pull request #677: Ftr: support get/post/put/patch in rest protocol

Posted by GitBox <gi...@apache.org>.
benbochong commented on a change in pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677#discussion_r462858369



##########
File path: protocol/rest/server/server_impl/go_restful_server.go
##########
@@ -82,23 +83,39 @@ func (grs *GoRestfulServer) Start(url common.URL) {
 
 // Publish a http api in go-restful server
 // The routeFunc should be invoked when the server receive a request
-func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) {
-	ws := &restful.WebService{}
+func (grs *GoRestfulServer) Deploy(restServiceConfig *config.RestServiceConfig, invoker protocol.Invoker) {
+	/*ws := &restful.WebService{}
 	rf := func(req *restful.Request, resp *restful.Response) {
 		routeFunc(NewGoRestfulRequestAdapter(req), resp)
 	}
 	ws.Path(restMethodConfig.Path).
 		Produces(strings.Split(restMethodConfig.Produces, ",")...).
 		Consumes(strings.Split(restMethodConfig.Consumes, ",")...).
 		Route(ws.Method(restMethodConfig.MethodType).To(rf))
-	grs.container.Add(ws)
+	grs.container.Add(ws)*/
 
+	ws := &restful.WebService{}
+	ws.Path(restServiceConfig.Path)

Review comment:
       You don't have to set the root path. The following configurations are completely equivalent.
   
   ```
   services:
     "CourseProvider":
       registry: "etcd"
       protocol : "rest"
       interface : "com.llll.Course"
       loadbalance: "random"
       warmup: "100"
       cluster: "failover"
       rest_path: "/courses"
       rest_produces: "application/json;charset=utf-8"
       rest_consumes: "application/json;charset=utf-8,*/*"
       methods:
       - name: "ViewList"
         rest_path: "/"
         rest_method: "GET"
       - name: "ViewOne"
         rest_path: "/{id}"
         rest_path_params: "0:id"
         rest_method: "GET"
       - name: "CreateDoc"
         rest_path: "/"
         rest_body: 0
         rest_method: "POST"
       - name: "EditDoc"
         rest_path: "/{id}"
         rest_path_params: "0:id"
         rest_body: 1
         rest_method: "PUT"
   ```
   
   ```
   services:
     "CourseProvider":
       registry: "etcd"
       protocol : "rest"
       interface : "com.llll.Course"
       loadbalance: "random"
       warmup: "100"
       cluster: "failover"
       rest_produces: "application/json;charset=utf-8"
       rest_consumes: "application/json;charset=utf-8,*/*"
       methods:
       - name: "ViewList"
         rest_path: "/courses"
         rest_method: "GET"
       - name: "ViewOne"
         rest_path: "/courses/{id}"
         rest_path_params: "0:id"
         rest_method: "GET"
       - name: "CreateDoc"
         rest_path: "/courses"
         rest_body: 0
         rest_method: "POST"
       - name: "EditDoc"
         rest_path: "/courses/{id}"
         rest_path_params: "0:id"
         rest_body: 1
         rest_method: "PUT"
   ```




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


[GitHub] [dubbo-go] Patrick0308 commented on pull request #677: Ftr: support get/post/put/patch in rest protocol

Posted by GitBox <gi...@apache.org>.
Patrick0308 commented on pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677#issuecomment-667767924


   I think #676 is better, so I will close this pr.


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


[GitHub] [dubbo-go] benbochong commented on a change in pull request #677: rest协议支持单url的get、post、put、patch方法

Posted by GitBox <gi...@apache.org>.
benbochong commented on a change in pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677#discussion_r462201535



##########
File path: protocol/rest/server/server_impl/go_restful_server.go
##########
@@ -82,23 +83,39 @@ func (grs *GoRestfulServer) Start(url common.URL) {
 
 // Publish a http api in go-restful server
 // The routeFunc should be invoked when the server receive a request
-func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) {
-	ws := &restful.WebService{}
+func (grs *GoRestfulServer) Deploy(restServiceConfig *config.RestServiceConfig, invoker protocol.Invoker) {
+	/*ws := &restful.WebService{}
 	rf := func(req *restful.Request, resp *restful.Response) {
 		routeFunc(NewGoRestfulRequestAdapter(req), resp)
 	}
 	ws.Path(restMethodConfig.Path).
 		Produces(strings.Split(restMethodConfig.Produces, ",")...).
 		Consumes(strings.Split(restMethodConfig.Consumes, ",")...).
 		Route(ws.Method(restMethodConfig.MethodType).To(rf))
-	grs.container.Add(ws)
+	grs.container.Add(ws)*/
 
+	ws := &restful.WebService{}
+	ws.Path(restServiceConfig.Path)

Review comment:
       Config different root path for different service




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


[GitHub] [dubbo-go] Patrick0308 commented on a change in pull request #677: rest协议支持单url的get、post、put、patch方法

Posted by GitBox <gi...@apache.org>.
Patrick0308 commented on a change in pull request #677:
URL: https://github.com/apache/dubbo-go/pull/677#discussion_r462067269



##########
File path: protocol/rest/server/server_impl/go_restful_server.go
##########
@@ -82,23 +83,39 @@ func (grs *GoRestfulServer) Start(url common.URL) {
 
 // Publish a http api in go-restful server
 // The routeFunc should be invoked when the server receive a request
-func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) {
-	ws := &restful.WebService{}
+func (grs *GoRestfulServer) Deploy(restServiceConfig *config.RestServiceConfig, invoker protocol.Invoker) {
+	/*ws := &restful.WebService{}
 	rf := func(req *restful.Request, resp *restful.Response) {
 		routeFunc(NewGoRestfulRequestAdapter(req), resp)
 	}
 	ws.Path(restMethodConfig.Path).
 		Produces(strings.Split(restMethodConfig.Produces, ",")...).
 		Consumes(strings.Split(restMethodConfig.Consumes, ",")...).
 		Route(ws.Method(restMethodConfig.MethodType).To(rf))
-	grs.container.Add(ws)
+	grs.container.Add(ws)*/
 
+	ws := &restful.WebService{}
+	ws.Path(restServiceConfig.Path)

Review comment:
       It will make user can't define same service path.




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