io.afu.utils.component.nginx.UpstreamServer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utils Show documentation
Show all versions of utils Show documentation
RffanLAB Utils For Many Way use
package io.afu.utils.component.nginx;
import io.afu.utils.common.constant.ConstantEnum;
import io.afu.utils.exception.BaseException;
public class UpstreamServer {
private String type; //类型 普通http还是unix 默认为null时是普通的Http
private String uri;// 访问地址
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getUpstreamServer() throws BaseException{
if (type == null || type.equals("http") || type.equals("https")){
// TODO 需要做以下检测检测是否是不包含路径的
return "server "+uri+";";
}else if (type.equals("unixsock")){
if (!uri.endsWith(".sock")){
throw new BaseException(ConstantEnum.NGINX_UNIX_UPSTREAM_MUST_BE_UNIX_SOCK_FILE);
}
return "unix:"+uri+";";
}
return null;
}
}