-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
I have a few HttpController
s and HttpSimpleController
s mixed together, and noticed today that only one of the HttpController
s was returning status 400, which is a status code I use for incorrect input in the URL.
I went exactly to the controller in question and added a print statement to check if it was the one getting called, and it turns out it isn't.
I then prefixed its URI with something that differs from all the other controllers and then I hit the new URI, and it returned a status 200.
I went to another controller which has about the same structure but has a constant in its URI, and put a print statement and saw it had been hitting that incorrect API endpoint.
To Reproduce
Couldn't reproduce it within a small project, here's how the two API endpoints in question roughly look like:
class Get : public HttpController<Get>
{
public:
void asyncHandleHttpRequest(
const HttpRequestPtr& req,
std::function<void (const HttpResponsePtr&)>&& callback,
string&& city,
string&& id
);
METHOD_LIST_BEGIN
ADD_METHOD_TO(
Get::asyncHandleHttpRequest,
"/api/clients/{client-city}/{client-id}",
HttpMethod::Get,
);
METHOD_LIST_END
};
class Get2 : public HttpController<Get2>
{
public:
void asyncHandleHttpRequest(
const HttpRequestPtr& req,
std::function<void (const HttpResponsePtr&)>&& callback,
string&& id
);
METHOD_LIST_BEGIN
ADD_METHOD_TO(
Get2::asyncHandleHttpRequest,
"/api/clients/users/{user-id}",
HttpMethod::Get,
);
METHOD_LIST_END
};
Here the API endpoint that overshadowed the other was Get
.
Will see if I can make a reproduceable example instead once I have time.
Expected behavior
Should have hit the API endpoint that looks closest to the actual URL.