public static Collection<String> getSuffixes(Method method) { Set<String> suffixes = new LinkedHashSet<>(); for (String produces : getProduces(method)) { int i = produces.lastIndexOf('/') + 1; String type = StringUtils.removeStart(produces.substring(i).toLowerCase(), "x-"); suffixes.add(type); } return suffixes; }
/** * Sets the engine for it's specified content type. An suffix for the engine is also registered based on the * specific type; extension types are supported and the leading "x-" is trimmed out. * * @param engine */ public void setContentTypeEngine(ContentTypeEngine engine) { String contentType = engine.getContentType(); String suffix = StringUtils.removeStart(contentType.substring(contentType.lastIndexOf('/') + 1), "x-"); engines.put(engine.getContentType(), engine); suffixes.put(suffix.toLowerCase(), engine); log.debug("'{}' content engine is '{}'", engine.getContentType(), engine.getClass().getName()); }
@Override public void redirect(String nameOrUriPattern, Map<String, Object> parameters) { String uri = uriFor(nameOrUriPattern, parameters); String applicationPath = application.getRouter().getApplicationPath(); if (!applicationPath.isEmpty()) { // remove application path uri = StringUtils.removeStart(uri.substring(applicationPath.length()), "/"); } redirect(uri); }
public List<String> toList(List<String> defaultValue) { if (isNull() || (values.length == 1 && StringUtils.isNullOrEmpty(values[0]))) { return defaultValue; } if (values.length == 1) { String tmp = values[0]; tmp = StringUtils.removeStart(tmp, "["); tmp = StringUtils.removeEnd(tmp, "]"); return StringUtils.getList(tmp, "(,|\\|)"); } return Arrays.asList(values); }
paths.add(StringUtils.removeEnd(parentPath, "/") + "/" + StringUtils.removeStart(path, "/"));
initFilterPath(filterConfig); String applicationPath = StringUtils.addEnd(contextPath, "/") + StringUtils.removeStart(filterPath, "/"); application.getRouter().setApplicationPath(applicationPath);
String path = Stream.of(StringUtils.removeEnd(controllerPath, "/"), StringUtils.removeStart(methodPath, "/")) .filter(Objects::nonNull) .collect(Collectors.joining("/"));
String undertowPropName = StringUtils.removeStart(propertyName, prefix); String typeName = getTypeName(undertowPropName); if (StringUtils.isNullOrEmpty(typeName))
@Override public void init(Application application) { super.init(application); PippoSettings pippoSettings = getPippoSettings(); TemplateConfiguration configuration = new TemplateConfiguration(); configuration.setBaseTemplateClass(PippoGroovyTemplate.class); configuration.setAutoEscape(true); if (pippoSettings.isDev()) { // Do not cache templates in dev mode configuration.setCacheTemplates(false); } else { configuration.setAutoIndent(true); configuration.setAutoNewLine(true); configuration.setAutoIndentString(" "); } String pathPrefix = getTemplatePathPrefix(); pathPrefix = StringUtils.removeStart(pathPrefix, "/"); pathPrefix = StringUtils.removeEnd(pathPrefix, "/"); GroovyTemplateResolver cachingResolver = new GroovyTemplateResolver(pathPrefix); ClassLoader classLoader = getClass().getClassLoader(); // allow custom initialization init(application, configuration); engine = new MarkupTemplateEngine(classLoader, configuration, cachingResolver); }
public RouteRegistration contentTypeSuffixes(String... suffixes) { this.contentTypeSuffixes = new LinkedHashSet<>(); for (String suffix : suffixes) { contentTypeSuffixes.add(StringUtils.removeStart(suffix.trim(), ".").toLowerCase()); } return this; }
public RouteRegistration contentTypeSuffixes(String... suffixes) { this.contentTypeSuffixes = new LinkedHashSet<>(); for (String suffix : suffixes) { contentTypeSuffixes.add(StringUtils.removeStart(suffix.trim(), ".").toLowerCase()); } return this; }
protected String getExclusionExpression(Collection<String> paths) { String joined = paths.stream().map(path -> StringUtils.removeStart(path, "/")).collect(Collectors.joining("|")); return "^(?!/(" + joined + ")/).*"; }
public RouteRegistration contentTypeSuffixes(Collection<String> suffixes) { this.contentTypeSuffixes = new LinkedHashSet<>(); for (String suffix : suffixes) { contentTypeSuffixes.add(StringUtils.removeStart(suffix.trim(), ".").toLowerCase()); } return this; }
public static Collection<String> getSuffixes(Method method) { Set<String> suffixes = new LinkedHashSet<>(); for (String produces : getProduces(method)) { int i = produces.lastIndexOf('/') + 1; String type = StringUtils.removeStart(produces.substring(i).toLowerCase(), "x-"); suffixes.add(type); } return suffixes; }
public static Collection<String> getSuffixes(Method method) { Set<String> suffixes = new LinkedHashSet<>(); for (String produces : getProduces(method)) { int i = produces.lastIndexOf('/') + 1; String type = StringUtils.removeStart(produces.substring(i).toLowerCase(), "x-"); suffixes.add(type); } return suffixes; }
protected RouteRegistration addWebjarsResourceRoute(String basePath) { resourcePaths.add(StringUtils.removeStart(basePath, "/")); return GET(new WebjarsResourceHandler(basePath)); }
protected RouteRegistration addFileResourceRoute(String basePath, File directory) { resourcePaths.add(StringUtils.removeStart(basePath, "/")); return GET(new FileResourceHandler(basePath, directory)); }
protected RoutesModule addControllers() { String applicationPackage = Optional.fromNullable(settings.getApplicationPackage()).or(""); String controllerPackage = StringUtils.removeStart(applicationPackage + ".controllers", "."); String controllersPackage = settings.getString(Settings.Setting.application_controllersPackage, controllerPackage); return addControllers(controllersPackage); }
private void setMetricClass(Class<? extends Annotation> metricClass, String name) { this.metricClass = metricClass; this.metricName = name == null ? (getRequestMethod() + "." + StringUtils.removeStart(getUriPattern(), "/")) : name; }
pathPrefix = StringUtils.removeStart(pathPrefix, "/"); builder.addTemplateLocator(new ClassPathTemplateLocator(10, pathPrefix, MUSTACHE));