Skip to content
New issue

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

./entrypoint.go:25: undefined: api.RegisterYourServiceHandlerFromEndpoint #285

Closed
dong77 opened this issue Jan 4, 2017 · 4 comments
Closed

Comments

@dong77
Copy link

dong77 commented Jan 4, 2017

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?

@dong77
Copy link
Author

dong77 commented Jan 4, 2017

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

@dong77 dong77 closed this as completed Jan 4, 2017
@tamalsaha tamalsaha mentioned this issue Mar 30, 2017
1 task
@simjay
Copy link

simjay commented Apr 26, 2017

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

@tamalsaha
Copy link
Collaborator

@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 {
...
}
``

@simjay
Copy link

simjay commented Apr 26, 2017

Thank you @tamalsaha !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants