We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main import ( "context" "fmt" "github.com/micro/go-micro" proto "watching/proto" ) type Greeter struct{} func (g *Greeter) Hello(ctx context.Context, req *proto.HelloRequest, rsp *proto.HelloResponse) error { rsp.Greeting = "Hello " + req.Name return nil } func main() { // Create a new service. Optionally include some options here. service := micro.NewService( micro.Name("go.micro.api.greeter"), //micro.Registry(consul.NewRegistry(func(options *registry.Options) { // options.Addrs = []string{ // "127.0.0.1:8500", // } //})), ) // Init will parse the command line flags. service.Init() // Register handler proto.RegisterGreeterHandler(service.Server(), new(Greeter)) // Run the server if err := service.Run(); err != nil { fmt.Println(err) } }
直接使用默认的服务发现 mdns
mdns
go run main.go micro api
curl -H 'Content-Type: application/json' -d '{"name": "Asim"}' http://127.0.0.1:8080/greeter/hello 也可是使用postman 访问
curl -d 'service=go.micro.api.greeter' \ -d 'method=Greeter.Hello' \ -d 'request={"name": "Bob"}' \ http://localhost:8080/rpc {"greeting":"Hello Bob"}%
The text was updated successfully, but these errors were encountered:
No branches or pull requests
micro api 使用
main.go
直接使用默认的服务发现
mdns
启动服务
请求
http
http rpc
The text was updated successfully, but these errors were encountered: