package com.ssyf.common.security.filter;

import com.ssyf.common.security.domain.ClientContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 客户端上下文持有类
 *
 * @author huwei
 * @date 2023/9/17 10:39
 */
public class ClientContextHolder {

    private static final ThreadLocal<ClientContext> CONTAINER = new InheritableThreadLocal<>();


    public static ClientContext getContext() {
        return CONTAINER.get();
    }

    static void init(HttpServletRequest request , HttpServletResponse response){
        CONTAINER.set(new ClientContext(request ,response));
    }

    static void clear() {
        CONTAINER.remove();
    }
}