1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00
go-micro/examples/proxy/go
2020-12-26 15:17:20 +00:00
..
http_client.go Add examples 2020-12-26 15:17:20 +00:00
http_server.go Add examples 2020-12-26 15:17:20 +00:00
proxy.go Add examples 2020-12-26 15:17:20 +00:00
README.md Add examples 2020-12-26 15:17:20 +00:00
rpc_client.go Add examples 2020-12-26 15:17:20 +00:00
rpc_server.go Add examples 2020-12-26 15:17:20 +00:00

Go

This Go example uses vanilla net/http and the proxy

  • proxy.go: methods to call proxy
  • rpc_{client,server}.go: RPC client/server
  • http_{client,server}.go: HTTP client/server

RPC Example

Run proxy

micro proxy

Run server

# serves Say.Hello
go run rpc_server.go proxy.go

Run client

# calls go.micro.srv.greeter Say.Hello
go run rpc_client.go proxy.go

HTTP Example

Run proxy with proxy handler

micro proxy --handler=http

Run server

# serves /greeter
go run http_server.go proxy.go

Run client

# calls /greeter
go run http_client.go proxy.go