Commit 876da6b3 authored by CrioUser's avatar CrioUser
Browse files

Incremental updates

parent f2b34c16
package com.example.restservice;
class CreditCard {
String name;
String creditCardNumber;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCreditCardNumber() {
return creditCardNumber;
}
public void setCreditCardNumber(String creditCardNumber) {
this.creditCardNumber = creditCardNumber;
}
@Override
public String toString() {
return "CreditCard [creditCardNumber=" + creditCardNumber + ", name=" + name + "]";
};
}
\ No newline at end of file
......@@ -3,6 +3,8 @@ package com.example.restservice;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -14,7 +16,22 @@ public class GreetingController {
@GetMapping("/greeting")
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
System.out.println("Learn By Doing");
Greeting greetingMessage = new Greeting(counter.incrementAndGet(), String.format(template, name));
return greetingMessage;
}
@PostMapping("/json-request")
public String processJson(@RequestBody CreditCard creditCard) {
System.out.println("Thank you for providing your credit card details."
+ "We promise to take care of all your purchases from now on ;-) ");
System.out.println(creditCard);
return "You are the true Santa";
}
// Handy curl request.
// curl --header "Content-Type: application/json" \
// --request POST \
// --data '{"name":"Santa","creditCardNumber":"0202-2323-2323-1999"}' \
// http://localhost:8081/json-request
}
......@@ -8,6 +8,7 @@ public class RestServiceApplication {
public static void main(String[] args) {
SpringApplication.run(RestServiceApplication.class, args);
System.out.println("Will I be called?");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment