Class MvcUtils
java.lang.Object
org.springframework.cloud.gateway.server.mvc.common.MvcUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCached raw request body key.static final StringCircuitBreaker execution exception attribute name.static final StringClient response key.static final StringClient response input stream key.static final StringGateway route ID attribute name.static final StringGateway original request URL attribute name.static final StringGateway request URL attribute name.static final StringGateway route ID attribute name.static final StringPreserve-Host header attribute name.static final StringWeight attribute name. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddOriginalRequestUrl(org.springframework.web.servlet.function.ServerRequest request, URI url) static <T> Optional<T>cacheAndReadBody(org.springframework.web.servlet.function.ServerRequest request, Class<T> toClass) static ByteArrayInputStreamcacheBody(org.springframework.web.servlet.function.ServerRequest request) decodeQueryString(@Nullable String queryString, Charset charset) encodeQueryParams(org.springframework.util.MultiValueMap<String, String> params) static Stringstatic String[]expandMultiple(org.springframework.web.servlet.function.ServerRequest request, String... templates) expandMultiple(org.springframework.web.servlet.function.ServerRequest request, Collection<String> templates) static org.springframework.context.ApplicationContextgetApplicationContext(org.springframework.web.servlet.function.ServerRequest request) static <T> @Nullable TgetAttribute(org.springframework.web.servlet.function.ServerRequest request, String key) getGatewayAttributes(org.springframework.web.servlet.function.ServerRequest request) static ByteArrayInputStreamgetOrCacheBody(org.springframework.web.servlet.function.ServerRequest request) getUriTemplateVariables(org.springframework.web.servlet.function.ServerRequest request) static <K,V> Map<K, V> static voidputAttribute(org.springframework.web.servlet.function.ServerRequest request, String key, @Nullable Object value) static voidputUriTemplateVariables(org.springframework.web.servlet.function.ServerRequest request, Map<String, String> uriVariables) static <T> Optional<T>readBody(org.springframework.web.servlet.function.ServerRequest request, ByteArrayInputStream body, Class<T> toClass) static voidsetRequestUrl(org.springframework.web.servlet.function.ServerRequest request, URI url) static voidsetRouteId(org.springframework.web.servlet.function.ServerRequest request, @Nullable String routeId) static StringstripContextPath(org.springframework.web.servlet.function.ServerRequest request, String path) Removes the servlet context-path prefix from the given path.
-
Field Details
-
CACHED_REQUEST_BODY_ATTR
Cached raw request body key. -
CLIENT_RESPONSE_INPUT_STREAM_ATTR
Client response input stream key. -
CLIENT_RESPONSE_ATTR
Client response key. -
CIRCUITBREAKER_EXECUTION_EXCEPTION_ATTR
CircuitBreaker execution exception attribute name. -
GATEWAY_ATTRIBUTES_ATTR
Gateway route ID attribute name. -
GATEWAY_ORIGINAL_REQUEST_URL_ATTR
Gateway original request URL attribute name. -
GATEWAY_REQUEST_URL_ATTR
Gateway request URL attribute name. -
GATEWAY_ROUTE_ID_ATTR
Gateway route ID attribute name. -
PRESERVE_HOST_HEADER_ATTRIBUTE
Preserve-Host header attribute name. -
WEIGHT_ATTR
Weight attribute name.
-
-
Method Details
-
cacheAndReadBody
-
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
-
expandMultiple
public static List<String> expandMultiple(org.springframework.web.servlet.function.ServerRequest request, Collection<String> templates) -
expandMultiple
-
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
-
getUriTemplateVariables
-
putAttribute
-
putUriTemplateVariables
-
mergeMaps
-
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 pathpath- the path to strip the context path from (raw or decoded)- Returns:
- the path without the servlet context-path prefix
-
encodeQueryParams
-
decodeQueryString
-