2017-03-22 21:52:00 +00:00
|
|
|
package ba.steleks;
|
|
|
|
|
2017-03-28 19:34:24 +00:00
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
2017-03-22 21:52:00 +00:00
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
2017-03-28 19:34:24 +00:00
|
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
2017-04-01 12:00:40 +00:00
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
2017-03-28 19:34:24 +00:00
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
2017-04-01 12:00:40 +00:00
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
2017-03-28 19:34:24 +00:00
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
2017-03-22 21:52:00 +00:00
|
|
|
|
|
|
|
@SpringBootApplication
|
|
|
|
public class EventsApplication {
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
SpringApplication.run(EventsApplication.class, args);
|
|
|
|
}
|
|
|
|
}
|
2017-03-28 19:34:24 +00:00
|
|
|
|
|
|
|
@RefreshScope
|
|
|
|
@RestController
|
|
|
|
class MessageRestController {
|
|
|
|
|
|
|
|
@Value("${message:Hello default}")
|
|
|
|
private String message;
|
|
|
|
|
2017-04-01 12:00:40 +00:00
|
|
|
@Value("${user.password}")
|
|
|
|
private String password;
|
|
|
|
|
2017-03-28 19:34:24 +00:00
|
|
|
@RequestMapping("/message")
|
|
|
|
String getMessage() {
|
|
|
|
return this.message;
|
|
|
|
}
|
2017-04-01 12:00:40 +00:00
|
|
|
|
|
|
|
//@RequestMapping(path ="/temp", value = "/{id}", method = RequestMethod.GET)
|
|
|
|
//String getTemp(@PathVariable("id") Long id){
|
|
|
|
// return "temp " + Long.toString(id);
|
|
|
|
//}
|
|
|
|
|
|
|
|
@RequestMapping(value = "/whoami/{user}", method = RequestMethod.GET)
|
|
|
|
public String whoami(@PathVariable("username") String username) {
|
|
|
|
return String.format("Hello! You're %s and you'll become a(n) root, " +
|
|
|
|
"but only if your password is '%s'!\n",
|
|
|
|
username, password);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|