package com.market.utils;

import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * 与 spot 一致：从请求头 {@code lang} 读取语言，未传时默认 zh_CN。
 */
public final class RequestUtils {

    private RequestUtils() {
    }

    public static String getLangFromHeader(HttpServletRequest request) {
        if (request == null) {
            return "zh_CN";
        }
        String lang = request.getHeader("lang");
        if (!StringUtils.hasText(lang)) {
            return "zh_CN";
        }
        return lang.trim();
    }
}
