Skip to content

Instantly share code, notes, and snippets.

@geraldoyudo
Created September 10, 2018 19:38
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 geraldoyudo/31acd88ee31a9e1af0589da9831ccf2f to your computer and use it in GitHub Desktop.
Save geraldoyudo/31acd88ee31a9e1af0589da9831ccf2f to your computer and use it in GitHub Desktop.
java-tutorials/api-error-handling/hello-controller-intro
@RestController
public class HelloController {
@PostMapping(path = "/sayHello")
public HelloResponse sayHello(@RequestBody HelloRequest request){
if(request.getName().contains("-")){
throw new SyntaxException();
}
return HelloResponse.builder()
.message(String.format("Hello %s!!", request.getName()))
.build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment