Skip to content

[BUG] API is probably broken for GetQueries per each method #744

@amills-vibeirl

Description

@amills-vibeirl

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

This API is inconsistent with the rest of the API:

if err := r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
	pathTemplate, err1 := route.GetPathTemplate()
	var queries, err2 = route.GetQueriesRegexp()

	if err1 == nil && err2 == nil {
		var methods, _ = route.GetMethods()

		for _, m := range methods {
			fmt.Println("ROUTE:", pathTemplate, route.GetName(), m, queries)
		}

	}
	return nil
}); err != nil {
	vibelog.Stdout.Error(err)
	os.Exit(1)
}

the problem is if we do this:

r.Methods("POST").Path("/v1/conversations").Queries("AAA","BBB").HandlerFunc(
  mw.Middleware(
	createNewChatConversation(c),
),
)

r.Methods("GET").Path("/v1/conversations").Queries("THIS IS NOT","THE SAME QUERIES").HandlerFunc(
  mw.Middleware(
	  doSomethingElse(c),
  ),
)

for the same route, for different methods, there are DIFFERENT Queries attached, but with route.GetQueries, it is just returning one object when it should return different objects for different methods.

Right?

Expected Behavior

Different Queries returned for different methods for the same Path

Steps To Reproduce

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions