Skip to content

Instantly share code, notes, and snippets.

@bytekast
Created March 25, 2017 20:42
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 bytekast/87578028e3e59b81dbe77d2bec1a32ce to your computer and use it in GitHub Desktop.
Save bytekast/87578028e3e59b81dbe77d2bec1a32ce to your computer and use it in GitHub Desktop.
@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