Skip to content

Instantly share code, notes, and snippets.

@vyo
Created June 8, 2017 13:05
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 vyo/096813730fc597fa3692007306ad4f24 to your computer and use it in GitHub Desktop.
Save vyo/096813730fc597fa3692007306ad4f24 to your computer and use it in GitHub Desktop.
@Path("echo")
public class EchoController {
private EchoService echoService;
/**
* explicit default constructor;
* required by Jersey
*/
public EchoController() {
echoService = new EchoService();
}
/**
* test constructor;
* required for full control during unit testing
*/
@TestConstructor
public EchoController(EchoService echoService) {
this.echoService = echoService;
}
@GET
@Path("{echo}")
@Produces(MediaType.TEXT_PLAIN)
public Echo echo(@PathParam("echo") String echo) {
return new Echo(echoService.reverse(echo));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment