Same endpoint, with and without @RequestParam

Viewed 1476

In Spring Boot is it possible to have the same endpoint with and without @RequestParam

A would look like this:

@GetMapping(value = "/billing-codes")
public ResponseEntity getBillingCodes(
        @AuthenticationPrincipal User loggedInUser,
        @RequestParam(name = "billingCodeId") String billingCodeId,
        @RequestParam(name = "direction") String direction,
        @RequestParam(name = "limit") String limit) {

B would look like this:

@GetMapping(value = "/billing-codes")
public ResponseEntity getBillingCodes(
        @AuthenticationPrincipal User loggedInUser) {

The requests would look different

A request

/billing-codes?billingCodeId=&direction=&limit

B request

/billing-codes

It is possible to test if the names of the request parameters are part of the request? Just testing if the request parameters are null or empty won't work since I will have case where they are and should still be processed in A.

1 Answers
Related