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

     1  # Greeter
     2  
     3  An example Greeter application
     4  
     5  ## Contents
     6  
     7  - **srv** - an RPC greeter service
     8  - **cli** - an RPC client that calls the service once
     9  - **api** - examples of RPC API and RESTful API
    10  - **web** - how to use go-web to write web services
    11  
    12  ## Run Service
    13  
    14  Start go.micro.srv.greeter
    15  ```shell
    16  go run srv/main.go
    17  ```
    18  
    19  ## Client
    20  
    21  Call go.micro.srv.greeter via client
    22  ```shell
    23  go run cli/main.go
    24  ```
    25  
    26  Examples of client usage via other languages can be found in the client directory.
    27  
    28  ## API
    29  
    30  HTTP based requests can be made via the micro API. Micro logically separates API services from backend services. By default the micro API 
    31  accepts HTTP requests and converts to *api.Request and *api.Response types. Find them here [micro/api/proto](https://github.com/micro/micro/tree/master/api/proto).
    32  
    33  Run the go.micro.api.greeter API Service
    34  ```shell
    35  go run api/api.go 
    36  ```
    37  
    38  Run the micro API
    39  ```shell
    40  micro api --handler=api
    41  ```
    42  
    43  Call go.micro.api.greeter via API
    44  ```shell
    45  curl http://localhost:8080/greeter/say/hello?name=John
    46  ```
    47  
    48  Examples of other API handlers can be found in the API directory.
    49  
    50  ## Web
    51  
    52  The micro web is a web dashboard and reverse proxy to run web apps as microservices.
    53  
    54  Run go.micro.web.greeter
    55  ```
    56  go run web/web.go 
    57  ```
    58  
    59  Run the micro web
    60  ```shell
    61  micro web
    62  ```
    63  
    64  Browse to http://localhost:8082/greeter