All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.afu.utils.component.nginx.UpstreamServer Maven / Gradle / Ivy

There is a newer version: 0.0.55-RELEASE
Show newest version
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;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy