Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 4, 2019 04:11
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 parzibyte/e93f54f624c69f50227375ad419f627b to your computer and use it in GitHub Desktop.
Save parzibyte/e93f54f624c69f50227375ad419f627b to your computer and use it in GitHub Desktop.
package hello;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment