github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/api/rpc/README.md (about)

     1  # RPC API
     2  
     3  This example makes use of the micro API with the RPC handler.
     4  
     5  The api in this mode lets you serve http while routing to standard go-micro services via RPC.
     6  
     7  The micro api with rpc handler only supports POST method and expects content-type of application/json or application/protobuf.
     8  
     9  ## Usage
    10  
    11  Run the micro API with the rpc handler
    12  
    13  ```
    14  micro api --handler=rpc
    15  ```
    16  
    17  Run this example
    18  
    19  ```
    20  go run rpc.go
    21  ```
    22  
    23  Make a POST request to /example/call which will call go.micro.api.example Example.Call
    24  
    25  ```
    26  curl -H 'Content-Type: application/json' -d '{"name": "john"}' "http://localhost:8080/example/call"
    27  ```
    28  
    29  Make a POST request to /example/foo/bar which will call go.micro.api.example Foo.Bar
    30  
    31  ```
    32  curl -H 'Content-Type: application/json' -d '{}' http://localhost:8080/example/foo/bar
    33  ```