GoogleCloudPlatform / go-endpoints

Cloud Endpoints for Go
https://go-endpoints.appspot.com
Apache License 2.0
255 stars 56 forks source link

RegisterServiceWithDefaults doesn't work #84

Open tristancaron opened 9 years ago

tristancaron commented 9 years ago

Hello,

I haven't found an example using this method, so I tried by my self. But it doesn't work.

 ptxService := &PtxService{}
    ptzService := &PtzService{}
  apiPtx, err := endpoints.RegisterService(ptxService, "ptx", "v1", "Ptx API", true)
  if err != nil {
    panic(err.Error())
  }
  apiPtz, err := endpoints.RegisterServiceWithDefaults(ptzService)
    if err != nil {
        panic(err.Error())
    }

    registerPtx := func(orig, name, method, path, desc string) {
      m := apiPtx.MethodByName(orig)
      if m == nil {
        panic("No methods found.")
      }
      i := m.Info()
      i.Name, i.HTTPMethod, i.Path, i.Desc = name, method, path, desc
  }

  registerPtz := func(orig, name, method, path, desc string) {
      m := apiPtz.MethodByName(orig)
      if m == nil {
        panic("No methods found.")
      }
      i := m.Info()
      i.Name, i.HTTPMethod, i.Path, i.Desc = name, method, path, desc
  }

  registerPtx("Connect", "connect", "GET", "connect", "Connect.")
    registerPtz("Estimation", "ptz.estimation", "GET", "ptz/estimation", "Get some informations.")

  endpoints.HandleHTTP()

It's a bug, or I'm missing something?

campoy commented 9 years ago

What do you mean by "it doesn't work" do you get any errors? Please describe.