Created
January 10, 2013 02:00
-
-
Save lucascs/4498748 to your computer and use it in GitHub Desktop.
A Routes parser that uses the last package name as the first level of uri: /package/controller/method
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 | |
@ApplicationScoped | |
public class PackageRoutesParser extends PathAnnotationRoutesParser { | |
//delegate constructor | |
public PackageRoutesParser(Router router) { | |
super(router); | |
} | |
@Override | |
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