Created
March 25, 2017 20:42
-
-
Save bytekast/87578028e3e59b81dbe77d2bec1a32ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@Log4j | |
@CompileStatic | |
class GetUsers implements Handler { | |
@Autowired | |
private UserRepository userRepository | |
@Override | |
boolean route(final Request request) { | |
request.resourcePath() == '/users' && request.httpMethod() == 'GET' | |
} | |
@Override | |
Response respond(final Request request) { | |
def allCustomers = userRepository.findAll() | |
Response.builder() | |
.statusCode(200) | |
.body(JsonOutput.prettyPrint(JsonOutput.toJson(allCustomers))) | |
.build() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment