package com.yn.bftl.thirdparty.common.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * url工具类
 * @author chendehuihuo
 * @date 2021/11/16
 */
public class UrlUtils {

    /**
     * 获取域名
     *
     * @return String
     */
    public static String getUrl(){
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = requestAttributes.getRequest();
        return  "http://" + request.getServerName() + ":" + request.getServerPort();
    }
}
