Manson
Manson
CC#
Created by Manson on 1/17/2023 in #help
How to differentiate endpoints based on parameters?
I guess I should ask is there a way to use the same url but differentiate by the use of query params? Coming from springboot you could do that so I was just wondering if there was an equivalent.
// /users
@GetMapping()
public User[] getAll() {
return users;
}

// /[email protected]&password=password
@GetMapping(params={"email", "password})
public User getByEmailAndPassword(
@RequestParam String email, // email
@RequestParam String password // password
) {
// Do whatever
return user;
}
// /users
@GetMapping()
public User[] getAll() {
return users;
}

// /[email protected]&password=password
@GetMapping(params={"email", "password})
public User getByEmailAndPassword(
@RequestParam String email, // email
@RequestParam String password // password
) {
// Do whatever
return user;
}
5 replies
CC#
Created by Manson on 1/17/2023 in #help
How to differentiate endpoints based on parameters?
I can't use query params without changing the endpoint? I know I can just do api/users/1 but I would like to be able to user api/users?=1
5 replies