Skip to content

Instantly share code, notes, and snippets.

@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(method = RequestMethod.GET)
public Observable<List<User>> find() {
return userService.findAll().toList();
@Component
public class UserService {
public Observable<User> findAll() {
return Observable.<User>from(new User[] {new User("Shazin", 29), new User("Shahim", 29)});
}
public Observable<User> findByName(String name) {
return findAll().filter(u -> u.getName().toLowerCase().contains(name.toLowerCase()));
}