java.lang.Object
org.springframework.cloud.gateway.server.mvc.common.MvcUtils

public abstract class MvcUtils extends Object
  • Field Details

    • CACHED_REQUEST_BODY_ATTR

      public static final String CACHED_REQUEST_BODY_ATTR
      Cached raw request body key.
    • CLIENT_RESPONSE_INPUT_STREAM_ATTR

      public static final String CLIENT_RESPONSE_INPUT_STREAM_ATTR
      Client response input stream key.
    • CLIENT_RESPONSE_ATTR

      public static final String CLIENT_RESPONSE_ATTR
      Client response key.
    • CIRCUITBREAKER_EXECUTION_EXCEPTION_ATTR

      public static final String CIRCUITBREAKER_EXECUTION_EXCEPTION_ATTR
      CircuitBreaker execution exception attribute name.
    • GATEWAY_ATTRIBUTES_ATTR

      public static final String GATEWAY_ATTRIBUTES_ATTR
      Gateway route ID attribute name.
    • GATEWAY_ORIGINAL_REQUEST_URL_ATTR

      public static final String GATEWAY_ORIGINAL_REQUEST_URL_ATTR
      Gateway original request URL attribute name.
    • GATEWAY_REQUEST_URL_ATTR

      public static final String GATEWAY_REQUEST_URL_ATTR
      Gateway request URL attribute name.
    • GATEWAY_ROUTE_ID_ATTR

      public static final String GATEWAY_ROUTE_ID_ATTR
      Gateway route ID attribute name.
    • PRESERVE_HOST_HEADER_ATTRIBUTE

      public static final String PRESERVE_HOST_HEADER_ATTRIBUTE
      Preserve-Host header attribute name.
    • WEIGHT_ATTR

      public static final String WEIGHT_ATTR
      Weight attribute name.
  • Method Details

    • cacheAndReadBody

      public static <T> Optional<T> cacheAndReadBody(org.springframework.web.servlet.function.ServerRequest request, Class<T> toClass)
    • cacheBody

      public static ByteArrayInputStream cacheBody(org.springframework.web.servlet.function.ServerRequest request)
    • getOrCacheBody

      public static ByteArrayInputStream getOrCacheBody(org.springframework.web.servlet.function.ServerRequest request)
    • expand

      public static String expand(org.springframework.web.servlet.function.ServerRequest request, String template)
    • expandMultiple

      public static List<String> expandMultiple(org.springframework.web.servlet.function.ServerRequest request, Collection<String> templates)
    • expandMultiple

      public static String[] expandMultiple(org.springframework.web.servlet.function.ServerRequest request, String... templates)
    • getApplicationContext

      public static org.springframework.context.ApplicationContext getApplicationContext(org.springframework.web.servlet.function.ServerRequest request)
    • getAttribute

      public static <T> @Nullable T getAttribute(org.springframework.web.servlet.function.ServerRequest request, String key)
    • getGatewayAttributes

      public static Map<String,Object> getGatewayAttributes(org.springframework.web.servlet.function.ServerRequest request)
    • getUriTemplateVariables

      public static Map<String,Object> getUriTemplateVariables(org.springframework.web.servlet.function.ServerRequest request)
    • putAttribute

      public static void putAttribute(org.springframework.web.servlet.function.ServerRequest request, String key, @Nullable Object value)
    • putUriTemplateVariables

      public static void putUriTemplateVariables(org.springframework.web.servlet.function.ServerRequest request, Map<String,String> uriVariables)
    • mergeMaps

      public static <K, V> Map<K,V> mergeMaps(@Nullable Map<K,V> left, @Nullable Map<K,V> right)
    • readBody

      public static <T> Optional<T> readBody(org.springframework.web.servlet.function.ServerRequest request, ByteArrayInputStream body, Class<T> toClass)
    • setRouteId

      public static void setRouteId(org.springframework.web.servlet.function.ServerRequest request, @Nullable String routeId)
    • setRequestUrl

      public static void setRequestUrl(org.springframework.web.servlet.function.ServerRequest request, URI url)
    • addOriginalRequestUrl

      public static void addOriginalRequestUrl(org.springframework.web.servlet.function.ServerRequest request, URI url)
    • stripContextPath

      public static String stripContextPath(org.springframework.web.servlet.function.ServerRequest request, String path)
      Removes the servlet context-path prefix from the given path. This ensures path-manipulating filters (e.g., StripPrefix, RewritePath) operate on the same path that route predicates match against.
      Parameters:
      request - the server request used to obtain the context path
      path - the path to strip the context path from (raw or decoded)
      Returns:
      the path without the servlet context-path prefix
    • encodeQueryParams

      public static org.springframework.util.MultiValueMap<String,String> encodeQueryParams(org.springframework.util.MultiValueMap<String,String> params)
    • decodeQueryString

      public static org.springframework.util.MultiValueMap<String,String> decodeQueryString(@Nullable String queryString, Charset charset)