mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
4.0.3
This commit is contained in:
@@ -3,6 +3,7 @@ package com.gitee.sop.gateway.interceptor;
|
||||
import com.gitee.sop.gatewaycommon.interceptor.RouteInterceptor;
|
||||
import com.gitee.sop.gatewaycommon.interceptor.RouteInterceptorContext;
|
||||
import com.gitee.sop.gatewaycommon.param.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -11,20 +12,23 @@ import org.springframework.stereotype.Component;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MyRouteInterceptor implements RouteInterceptor {
|
||||
|
||||
@Override
|
||||
public void preRoute(RouteInterceptorContext context) {
|
||||
ApiParam apiParam = context.getApiParam();
|
||||
System.out.println(String.format("请求接口:%s, ip:%s", apiParam.fetchNameVersion(), apiParam.fetchIp()));
|
||||
log.info("请求接口:{}, ip:{}", apiParam.fetchNameVersion(), apiParam.fetchIp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterRoute(RouteInterceptorContext context) {
|
||||
ServiceInstance serviceInstance = context.getServiceInstance();
|
||||
System.out.println("请求成功,serviceId:" + serviceInstance.getServiceId() + "(" + serviceInstance.getHost() + ":" + serviceInstance.getPort() + ")" +
|
||||
",微服务返回结果:" + context.getServiceResult());
|
||||
log.info("请求成功,serviceId:{}({}:{}),微服务返回结果:{}",
|
||||
serviceInstance.getServiceId(),
|
||||
serviceInstance.getHost(),serviceInstance.getPort(),
|
||||
context.getServiceResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user