2025-12-29 16:06:48 +08:00
|
|
|
package com.senmesh.security.util;
|
2025-06-11 09:42:13 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* request请求host上下文
|
|
|
|
|
* @author sr on 2021-08-23
|
|
|
|
|
*/
|
|
|
|
|
public class HostContextHolder {
|
|
|
|
|
|
|
|
|
|
private static final ThreadLocal<String> HOST = new ThreadLocal<String>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author sr on 2021-08-18
|
|
|
|
|
*/
|
|
|
|
|
public static void clearHost() {
|
|
|
|
|
HOST.remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param host
|
|
|
|
|
* @author sr on 2021-08-18
|
|
|
|
|
*/
|
|
|
|
|
public static void setHost(String host) {
|
|
|
|
|
HOST.set(host);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param host
|
|
|
|
|
* @author sr on 2021-08-18
|
|
|
|
|
*/
|
|
|
|
|
public static String getHost() {
|
|
|
|
|
return HOST.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|