Issue
One of my colleagues uses =
as shown below for path variables and it surprisingly (to me) works. However, I have never seen examples of it in any tutorials.
@GetMapping("/getCustomFieldBy={portId}")
public ResponseEntity getMempools(@PathVariable Long portId) {
return ResponseEntity.ok(customFieldService.findByPortId(portId));
}
I expect a /
inside the pathname. Is there a name for this syntax or is it even standard? How do I look it up?
Solution
It is not a strange syntax, it's a valid and literal mapping of the =
character. These are examples of valid endpoints that the mapping intercepts:
localhost:8080/getCustomFieldBy=8009
localhost:8080/getCustomFieldBy=15123
It is not a standard nor a convention to use =
. A typical REST endpoint would look rather like this:
localhost:8080/customField?port=8009
Answered By - Nikolas Charalambidis