Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A Routes parser that uses the last package name as the first level of uri: /package/controller/method
public class PackageRoutesParser extends PathAnnotationRoutesParser {
//delegate constructor
public PackageRoutesParser(Router router) {
protected String extractControllerNameFrom(Class<?> type) {
return "/" + extractPackage(type) + super.extractControllerNameFrom(type);
private String extractPackage(Class<?> type) {
String[] subpackages = type.getPackage().getName().split("\\.");
return subpackages[subpackages.length - 1]; //last
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.