Skip to content

Instantly share code, notes, and snippets.

@aarshtalati
Last active March 28, 2018 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarshtalati/ca16401fa5dbe696d770272c3752a573 to your computer and use it in GitHub Desktop.
Save aarshtalati/ca16401fa5dbe696d770272c3752a573 to your computer and use it in GitHub Desktop.
package edu.gatech.epidemics.api;
import edu.gatech.epidemics.model.User;
import edu.gatech.epidemics.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* @author atalati
* /api/user
*/
@RestController
public class UserApiController {
@Autowired
Environment environment;
@Autowired
private UserService userService;
/*
GET: /api/user/
Returns all users from the database
*/
@GetMapping(value = "/api/user")
public List<User> get() {
return userService.findAll();
}
@GetMapping(value = "/api/user/{id}")
public User get(@PathVariable int id) {
return userService.findById(id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment