ren.yale.java.tools.PathParamConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Summer Show documentation
Show all versions of Summer Show documentation
Summer is a web server which connect JAX-RS and Vertx
The newest version!
package ren.yale.java.tools;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Yale
* Convert JAX-RS path param /{id}/ to Vertx-Web path param pattern /:id/
* create at: 2018-02-01 9:49
**/
public class PathParamConverter {
public static String converter(String path){
if (path==null||path.length()==0){
return path;
}
Matcher matcher = Pattern.compile("\\{(.*?)\\}").matcher(path);
while (matcher.find()){
String p = matcher.group(0);
if (p.length()>0){
p = p.replace("{","").replace("}","");
path=path.replace(matcher.group(0),":"+p);
}
}
return path;
}
}