@Test public void requestReader_doubleBasePath() { ContainerConfig config = ContainerConfig.defaultConfig(); config.setStripBasePath(true); config.setServiceBasePath(BASE_PATH_MAPPING); String finalPath = requestReader.stripBasePath("/" + BASE_PATH_MAPPING + "/" + BASE_PATH_MAPPING, config); assertNotNull(finalPath); assertEquals("/" + BASE_PATH_MAPPING, finalPath); finalPath = requestReader.stripBasePath("/custom/" + BASE_PATH_MAPPING, config); assertNotNull(finalPath); assertEquals("/custom/" + BASE_PATH_MAPPING, finalPath); finalPath = requestReader.stripBasePath(BASE_PATH_MAPPING, config); assertNotNull(finalPath); assertEquals(BASE_PATH_MAPPING, finalPath); }
protected String stripBasePath(String requestPath, ContainerConfig config) { if (!config.isStripBasePath()) { return requestPath; } if (requestPath.startsWith(config.getServiceBasePath())) { String newRequestPath = requestPath.replaceFirst(config.getServiceBasePath(), ""); if (!newRequestPath.startsWith("/")) { newRequestPath = "/" + newRequestPath; } return newRequestPath; } return requestPath; }
RequestReader { protected String stripBasePath(String requestPath, ContainerConfig config) { if (!config.isStripBasePath()) { return requestPath; } if (requestPath.startsWith(config.getServiceBasePath())) { String newRequestPath = requestPath.replaceFirst(config.getServiceBasePath(), ""); if (!newRequestPath.startsWith("/")) { newRequestPath = "/" + newRequestPath; } return newRequestPath; } return requestPath; } }
RequestReader { protected String stripBasePath(String requestPath, ContainerConfig config) { if (!config.isStripBasePath()) { return requestPath; } if (requestPath.startsWith(config.getServiceBasePath())) { String newRequestPath = requestPath.replaceFirst(config.getServiceBasePath(), ""); if (!newRequestPath.startsWith("/")) { newRequestPath = "/" + newRequestPath; } return newRequestPath; } return requestPath; }  }
RequestReader { protected String stripBasePath(String requestPath, ContainerConfig config) { if (!config.isStripBasePath()) { return requestPath; } if (requestPath.startsWith(config.getServiceBasePath())) { String newRequestPath = requestPath.replaceFirst(config.getServiceBasePath(), ""); if (!newRequestPath.startsWith("/")) { newRequestPath = "/" + newRequestPath; } return newRequestPath; } return requestPath; }  abstract ContainerRequestType readRequest(RequestType request, SecurityContext securityContext, Context lambdaContext, ContainerConfig config); }
RequestReader { protected String stripBasePath(String requestPath, ContainerConfig config) { if (!config.isStripBasePath()) { return requestPath; } if (requestPath.startsWith(config.getServiceBasePath())) { String newRequestPath = requestPath.replaceFirst(config.getServiceBasePath(), ""); if (!newRequestPath.startsWith("/")) { newRequestPath = "/" + newRequestPath; } return newRequestPath; } return requestPath; }  abstract ContainerRequestType readRequest(RequestType request, SecurityContext securityContext, Context lambdaContext, ContainerConfig config); static final String API_GATEWAY_CONTEXT_PROPERTY; static final String API_GATEWAY_STAGE_VARS_PROPERTY; static final String ALB_CONTEXT_PROPERTY; static final String API_GATEWAY_EVENT_PROPERTY; static final String LAMBDA_CONTEXT_PROPERTY; static final String JAX_SECURITY_CONTEXT_PROPERTY; static final String HTTP_API_CONTEXT_PROPERTY; static final String HTTP_API_STAGE_VARS_PROPERTY; static final String HTTP_API_EVENT_PROPERTY; }