You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/27 12:47:33 UTC

[GitHub] [apisix] zhuliquan edited a comment on issue #3134: I have some trouble on route match

zhuliquan edited a comment on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751463366


   # GRPC service
   I use grpc build service
   protobuf:
   ```syntax="proto3";
   
   import "google/api/annotations.proto";
   package test_grpc.api.file;
   
   option go_package = ".;file";
   
   message Request {
     string uri = 1;
   }
   
   message Response {
     string info = 1;
   }
   
   service File {
     rpc GetFile (Request) returns (Response) {
       option (google.api.http) = {
         get: "/v1/{uri=files/*}"
       };
     }
     rpc ListReputationHistories (Request) returns (Response) {
       option (google.api.http) = {
         post: "/v1/files:listReputationHistories"
       };
     }
   }
   ```
   
   service code.
   
   ```
   func (s *FileServerImpl) GetFile(ctx context.Context, r *file.Request) (*file.Response, error) {
           return &file.Response{Info: "GetFile:" + r.GetUri()}, nil
   }
   func (s *FileServerImpl) ListReputationHistories(ctx context.Context, r *file.Request) (*file.Response, error) {
           return &file.Response{Info: "ListReputationHistories:" + r.GetUri()}, nil
   }
   ```
   I run service with prot:9201 .
   
   # APISIX
   upstreams: 
   ```
   curl -XPUT "http://127.0.0.1:9080/apisix/admin/upstreams/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1'  -d '{"nodes":{"host":"127.0.0.1:9201" : 1},  "type":"roundrobin", "name":"test_grpc_http"}'
   ```
   routes:
   ```
   curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files/*"],"name":"get_file1","methods":["GET"],"plugins":{"proxy-rewrite":{"regex_uri":["^/test/v1/files/(.+)","/v1/files/$1"]}},"upstream_id":"1"}'
   curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/2" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files:listReputationHistories"],"name":"list_reputation_history1","methods":["POST"],"plugins":{"proxy-rewrite":{"uri":"/v1/files:listReputationHistories"}},"upstream_id":"1"}'
   ```
   
   #Fact
   I send any post request with prefix ---/test/v1/files:--- , result is same with ---/test/v1/files:listReputationHistories---
   for example:
   curl "http://127.0.0.1:9080/test/v1/files:esxxx" -XPOST -d {"uri":"xxx"}
   {"info":"ListReputationHistories:"}(base)
   
   
   `


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