fix():连接鉴权报错信息
parent
67a64a51bb
commit
5bc3b40710
|
@ -19,10 +19,8 @@ public interface ClientAdmin {
|
|||
* @return 响应结果
|
||||
*/
|
||||
@Post(
|
||||
url = "{vehicleLoadUrl}"/*,
|
||||
headers = {
|
||||
"X-co-il: DH5I9OIG+N=="
|
||||
}*/
|
||||
url = "{vehicleLoadUrl}",
|
||||
interceptor = SimpleInterceptor.class
|
||||
)
|
||||
public Result<MqttServerModel> getVehicleLoadAddr ( @JSONBody VehicleConnectionReq vehicleConnectionReq);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.muyu.vehicle.api;
|
||||
|
||||
import com.dtflys.forest.http.ForestRequest;
|
||||
import com.dtflys.forest.interceptor.Interceptor;
|
||||
import com.muyu.system.constants.TokenConstants;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Log4j2
|
||||
@Component
|
||||
public class SimpleInterceptor<T> implements Interceptor<T> {
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
/**
|
||||
* 该方法在请求发送之前被调用, 若返回false则不会继续发送请求
|
||||
* @Param request Forest请求对象
|
||||
*/
|
||||
@Override
|
||||
public boolean beforeExecute(ForestRequest req) {
|
||||
// 执行在发送请求之前处理的代码
|
||||
req.addHeader(TokenConstants.AUTHENTICATION, request.getHeader(TokenConstants.AUTHENTICATION)); // 添加Header
|
||||
return true; // 继续执行请求返回true
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue