static io.vertx.core.http.HttpMethod toVertxMethod(String method) { try { return io.vertx.core.http.HttpMethod.valueOf(method); } catch (IllegalArgumentException e) { return io.vertx.core.http.HttpMethod.OTHER; } }
@Override public io.vertx.core.http.HttpMethod method() { if (method == null) { String sMethod = request.method().toString(); try { method = io.vertx.core.http.HttpMethod.valueOf(sMethod); } catch (IllegalArgumentException e) { method = io.vertx.core.http.HttpMethod.OTHER; } } return method; }
static io.vertx.core.http.HttpMethod toVertxMethod(String method) { try { return io.vertx.core.http.HttpMethod.valueOf(method); } catch (IllegalArgumentException e) { return io.vertx.core.http.HttpMethod.OTHER; } }
@Override public io.vertx.core.http.HttpMethod method() { if (method == null) { String sMethod = request.method().toString(); try { method = io.vertx.core.http.HttpMethod.valueOf(sMethod); } catch (IllegalArgumentException e) { method = io.vertx.core.http.HttpMethod.OTHER; } } return method; }
private HttpMethod getMethod() { OperationMeta operationMeta = invocation.getOperationMeta(); RestOperationMeta swaggerRestOperation = operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION); String method = swaggerRestOperation.getHttpMethod(); return HttpMethod.valueOf(method); }
final HttpMethod httpMethod = HttpMethod.valueOf(request.getMethod());
/** * Support CORS */ void mountCorsHandler(Router mainRouter) { if (!TransportConfig.isCorsEnabled()) { return; } CorsHandler corsHandler = getCorsHandler(TransportConfig.getCorsAllowedOrigin()); // Access-Control-Allow-Credentials corsHandler.allowCredentials(TransportConfig.isCorsAllowCredentials()); // Access-Control-Allow-Headers corsHandler.allowedHeaders(TransportConfig.getCorsAllowedHeaders()); // Access-Control-Allow-Methods Set<String> allowedMethods = TransportConfig.getCorsAllowedMethods(); for (String method : allowedMethods) { corsHandler.allowedMethod(HttpMethod.valueOf(method)); } // Access-Control-Expose-Headers corsHandler.exposedHeaders(TransportConfig.getCorsExposedHeaders()); // Access-Control-Max-Age int maxAge = TransportConfig.getCorsMaxAge(); if (maxAge >= 0) { corsHandler.maxAgeSeconds(maxAge); } LOGGER.info("mount CorsHandler"); mainRouter.route().handler(corsHandler); }
private Set<HttpMethod> getHttpMethodPropertiesAsList(final String propertyKey, final String defaultValue) { String property = environment.getProperty(propertyKey); if (property == null) { property = defaultValue; } return asList(property.replaceAll("\\s+","").split(",")) .stream() .map(method -> HttpMethod.valueOf(method)) .collect(Collectors.toSet()); } }
private Set<HttpMethod> getHttpMethodPropertiesAsList(final String propertyKey, final String defaultValue) { String property = environment.getProperty(propertyKey); if (property == null) { property = defaultValue; } return asList(property.replaceAll("\\s+","").split(",")) .stream() .map(method -> HttpMethod.valueOf(method)) .collect(Collectors.toSet()); } }
private static io.vertx.core.http.HttpMethod toVertxHttpMethod(HttpMethod supportedMethod) { return io.vertx.core.http.HttpMethod.valueOf(supportedMethod.name()); } }
private boolean isMethodAllowedInFlow(final HttpMethod method, KnotxFlowSettings flow) { return flow != null & flow.getRouting() != null && flow.getRouting().keySet().stream() .anyMatch(item -> HttpMethod.valueOf(item.toUpperCase()) == method); } }
private void parseMethodRouting(Map.Entry<String, Object> entry) { final List<RoutingEntry> methodCriteria = getMethodCriterias( HttpMethod.valueOf(entry.getKey())); ((JsonArray) entry.getValue()).stream() .map(item -> (JsonObject) item) .map(this::parseRoutingCriteria) .forEach(methodCriteria::add); }
private boolean isMethodAllowedInFlow(final HttpMethod method, KnotxFlowSettings flow) { return flow != null & flow.getRouting() != null && flow.getRouting().keySet().stream() .anyMatch(item -> HttpMethod.valueOf(item.toUpperCase()) == method); } }
HttpMethod.valueOf(step.getRequest().getMethod().name().toUpperCase()), port, hcRequestUri.getHost(), relativeUri);
private Optional<T> mapResponse(Response response) throws IOException, MeshRestClientMessageException { String body = response.body().string(); if (!response.isSuccessful()) { throw new MeshRestClientMessageException( response.code(), response.message(), JsonUtil.readValue(body, GenericMessageResponse.class), HttpMethod.valueOf(request.method().toUpperCase()), request.url().toString() ); } else { String contentType = response.header("Content-Type"); if (body.length() == 0) { return Optional.empty(); } else if (contentType != null && contentType.startsWith("application/json")) { return Optional.of(JsonUtil.readValue(body, resultClass)); } else if (resultClass.isAssignableFrom(String.class)) { return Optional.of((T) body); } else { throw new RuntimeException("Request can't be handled by this handler since the content type was {" + contentType + "}"); } } }
/** * @param object object */ public HttpRequest(JsonObject object) { this.method = HttpMethod.valueOf(object.getString("method")); this.uri = object.getString("uri"); if (method == null || uri == null) { throw new IllegalArgumentException("Request fields 'uri' and 'method' must be set"); } switch (method) { case GET: case PUT: case POST: case DELETE: break; default: throw new IllegalArgumentException("Request method must be one of GET, PUT, POST or DELETE"); } JsonArray headersArray = object.getJsonArray("headers"); if (headersArray != null) { this.headers = JsonMultiMap.fromJson(headersArray); } this.payload = object.getBinary("payload"); }
private HttpMethod getMethod(Invocation invocation) { OperationMeta operationMeta = invocation.getOperationMeta(); RestOperationMeta swaggerRestOperation = operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION); String method = swaggerRestOperation.getHttpMethod(); return HttpMethod.valueOf(method); }
private HttpMethod getMethod() { OperationMeta operationMeta = invocation.getOperationMeta(); RestOperationMeta swaggerRestOperation = operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION); String method = swaggerRestOperation.getHttpMethod(); return HttpMethod.valueOf(method); }
/** * Bind a handler to each operation. * * @param router the Vert.x router * @param config the plugin configuration * @param swagger the OpenAPI specification * @param path the mock path * @param pathConfig the path configuration */ private void handlePathOperations(Router router, OpenApiPluginConfig config, Swagger swagger, String path, Path pathConfig) { pathConfig.getOperationMap().forEach((httpMethod, operation) -> { final String fullPath = ofNullable(swagger.getBasePath()).orElse("") + convertPath(path); LOGGER.debug("Adding mock endpoint: {} -> {}", httpMethod, fullPath); // convert an {@link io.swagger.models.HttpMethod} to an {@link io.vertx.core.http.HttpMethod} final HttpMethod method = HttpMethod.valueOf(httpMethod.name()); router.route(method, fullPath).handler(buildHandler(config, swagger, operation)); }); }
public static void fromJson(JsonObject json, ClientRequest obj) { if (json.getValue("jsonFormAttributes") instanceof JsonObject) { obj.setJsonFormAttributes(((JsonObject)json.getValue("jsonFormAttributes")).copy()); } if (json.getValue("jsonHeaders") instanceof JsonObject) { obj.setJsonHeaders(((JsonObject)json.getValue("jsonHeaders")).copy()); } if (json.getValue("jsonParams") instanceof JsonObject) { obj.setJsonParams(((JsonObject)json.getValue("jsonParams")).copy()); } if (json.getValue("method") instanceof String) { obj.setMethod(io.vertx.core.http.HttpMethod.valueOf((String)json.getValue("method"))); } if (json.getValue("path") instanceof String) { obj.setPath((String)json.getValue("path")); } }