@Resource
@Path("/api/user")
public class UserController {
@Action(method = HttpMethod.GET, path = "/{id}")
@Response(entity = User.class)
public User getUser(@Param(name = "id", type = ValueType.INTEGER) int id) {
return UserRepository.getUserById(id);
}
@Action(method = HttpMethod.POST, path = "")
@Response(entity = User.class)
public User createUser(@Param(name = "username", type = ValueType.STRING) String username,
@Param(name = "password", type = ValueType.STRING) String password) {
User user = new User(username, password);
UserRepository.createUser(user);
return user;
}
}