Я хочу реализовать REST API в Java с «перегруженной» конечной точкой, которая отличается передаваемыми параметрами запроса.
Я пробовал этот код в своем классе контроллера:
@Get("/query")
public MyResponse queryByDate(@QueryValue @Valid @Format("yyyy-MM-dd") Date date) {
// Code to generate the response
return retval;
}
@Get("/query")
public MyResponse queryByDateAndValue(@QueryValue @Valid @Format("yyyy-MM-dd") Date date, @QueryValue int value) {
// Code to generate the response
return retval;
}
Это возвращает следующую ошибку:
More than 1 route matched the incoming request. The following routes matched /calendar/years/query: GET - /calendar/years/query, GET - /calendar/years/query
io.micronaut.web.router.exceptions.DuplicateRouteException: More than 1 route matched the incoming request. The following routes matched /calendar/years/query: GET - /calendar/years/query, GET - /calendar/years/query
Обратите внимание, что, если я удаляю один из методов, оставшийся метод работает должным образом. Как я могу сопоставить конечную точку с разными параметрами запроса двум различным методам в контроллере? Это возможно?
Спасибо.