Created
March 25, 2017 20:41
-
-
Save bytekast/6420277ab301107daa13de5f59100754 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 FindUsersByLastName implements Handler { | |
@Autowired | |
private UserRepository userRepository | |
@Override | |
boolean route(final Request request) { | |
request.resourcePath() == '/users/{lastName}' && request.httpMethod() == 'GET' | |
} | |
@Override | |
Response respond(final Request request) { | |
def customers = userRepository.findByLastName(request.pathParameter('lastName')) | |
Response.builder() | |
.statusCode(200) | |
.body(JsonOutput.prettyPrint(JsonOutput.toJson(customers))) | |
.build() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment