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

endpoint title & description not produced for handlers which are methods #11

Open
Robinnnnn opened this issue Aug 18, 2017 · 0 comments

Comments

@Robinnnnn
Copy link

My gorilla mux routes are set up using controllers so that each route has access to the app's runtime, which contains important config variables.

The handlers on the controller have a similar signature as the ones provided in the repo's example by accepting http.ReponseWriter and *http.Request as arguments with no return value. The only difference is that it's registered as methods on the controller. Here's the whole setup:

// router.go

package main

r := mux.NewRouter()
r.KeepContext = true
r.StrictSlash(true)
orgsRouter := r.PathPrefix("/v3.1/orgs").Subrouter()

oc := orgs.NewOrgController(runtime)
orgsRouter.HandleFunc("", oc.CreateOrgHandler).Methods("POST").Name("CreateOrgHandler")
orgsRouter.HandleFunc("/{org_irv_id}", oc.GetOrgHandler).Methods("GET").Name("GetOrgsAndAccessForUserHandler")
orgsRouter.HandleFunc("/{org_irv_id}", oc.UpdateOrgHandler).Methods("PUT").Name("GetOrgHandler")




// controller.go

package orgs

type OrgController struct {
	runtime *irv_core.IRV_runtime
}

func NewOrgController(runtime *irv_core.IRV_runtime) *OrgController {
	return &OrgController{runtime}
}

// CreateOrgHandler creates an org
func (oc OrgController) CreateOrgHandler(w http.ResponseWriter, r *http.Request){
  ...
}

// GetOrgHandler gets an org by ID
func (oc OrgController) GetOrgHandler(w http.ResponseWriter, r *http.Request) {
  ...
}

// UpdateOrgHandler updates an org by ID
func (oc OrgController) UpdateOrgHandler(w http.ResponseWriter, r *http.Request) {
  ...
}

Unfortunately the resulting .apib file looks unusual. None of the route names nor descriptions appear; instead, the raw URL is listed and all descriptions are labeled SERVE H T T P. Here's an excerpt:

...

## /v3.1/orgs/512df1c7-fef8-4e49-9f38-482f40534213

### Serve H T T P [GET]

...

## /v3.1/orgs/875a041d-57f2-4696-b596-a7ee3d9840e9

### Serve H T T P [PUT]

...

Please let me know if there's a possible fix here. Thanks!

@s-mang s-mang changed the title Setting up endpoint title, endpoint description endpoint title & description not produced for handlers which are methods Nov 20, 2017
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

1 participant