package com.sf.vertx.handle; import com.sf.vertx.api.pojo.AppConfig; import com.sf.vertx.api.pojo.MockResponse; import com.sf.vertx.constans.SacErrorCode; import io.vertx.ext.web.RoutingContext; import io.vertx.ext.web.handler.HttpException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @Slf4j public class ApiMockHandlerImpl implements ApiMockHandler { @Override public void handle(RoutingContext rc) { try { String cacheKey = AppConfigHandler.getApiCodeConfigCacheKey(rc); // mock MockResponse mockResponse = AppConfigHandler.mock(cacheKey,rc); if (mockResponse != null) { rc.fail(new MockException(mockResponse.getHttpStatus(), mockResponse.getMockResponse())); return; } } catch (Exception e) { e.printStackTrace(); rc.fail(new HttpException(SacErrorCode.DEFAULT_ERROR_CODE)); return; } rc.next(); } }