Grpc-gateway: ./entrypoint.go:25: undefined: api.RegisterYourServiceHandlerFromEndpoint

Created on 4 Jan 2017  路  4Comments  路  Source: grpc-ecosystem/grpc-gateway

I was trying to set up a small project with grpc-gateway, but encountered this error:

package main
import (
 "flag"
 "net/http"

 "github.com/golang/glog"
 "golang.org/x/net/context"
 "github.com/grpc-ecosystem/grpc-gateway/runtime"
 "google.golang.org/grpc"

 gw "dong.io/nextex/reverseproxy/api"
)

var (
 echoEndpoint = flag.String("echo_endpoint", "localhost:9090", "endpoint of YourService")
)

func run() error {
 ctx := context.Background()
 ctx, cancel := context.WithCancel(ctx)
 defer cancel()

 mux := runtime.NewServeMux()
 opts := []grpc.DialOption{grpc.WithInsecure()}
 err := gw.RegisterYourServiceHandlerFromEndpoint(ctx, mux, *echoEndpoint, opts)
 if err != nil {
   return err
 }

 http.ListenAndServe(":8080", mux)
 return nil
}

func main() {
 flag.Parse()
 defer glog.Flush()

 if err := run(); err != nil {
   glog.Fatal(err)
 }
}

I cannot find where RegisterYourServiceHandlerFromEndpoint is defined. Did I do someting wrong?

Most helpful comment

@simjay , grpc-gateway compiler will generate a method called gw.Register<YourService>HandlerFromEndpoint. <YourService> will be the service name you used in your proto file, eg,

` service MyService { ... }

All 4 comments

I got it, this method's name depends on my service name...

Could you tell me how you fixed this issue? Thanks in advance

@simjay , grpc-gateway compiler will generate a method called gw.Register<YourService>HandlerFromEndpoint. <YourService> will be the service name you used in your proto file, eg,

` service MyService { ... }

Thank you @TamalSaha !

Was this page helpful?
0 / 5 - 0 ratings