/** * An alternative to {@link #fromController(Class)} that accepts a * {@code UriComponentsBuilder} representing the base URL. This is useful * when using MvcUriComponentsBuilder outside the context of processing a * request or to apply a custom baseUrl not matching the current request. * <p><strong>Note:</strong> This method extracts values from "Forwarded" * and "X-Forwarded-*" headers if found. See class-level docs. * @param builder the builder for the base URL; the builder will be cloned * and therefore not modified and may be re-used for further calls. * @param controllerType the controller to build a URI for * @return a UriComponentsBuilder instance (never {@code null}) */ public static UriComponentsBuilder fromController(@Nullable UriComponentsBuilder builder, Class<?> controllerType) { builder = getBaseUrlToUse(builder); // Externally configured prefix via PathConfigurer.. String prefix = getPathPrefix(controllerType); builder.path(prefix); String mapping = getClassMapping(controllerType); builder.path(mapping); return builder; }
private static UriComponentsBuilder fromMethodInternal(@Nullable UriComponentsBuilder builder, Class<?> controllerType, Method method, Object... args) { builder = getBaseUrlToUse(builder); // Externally configured prefix via PathConfigurer.. String prefix = getPathPrefix(controllerType); builder.path(prefix); String typePath = getClassMapping(controllerType); String methodPath = getMethodMapping(method); String path = pathMatcher.combine(typePath, methodPath); builder.path(path); return applyContributors(builder, method, args); }
/** * An alternative to {@link #fromController(Class)} that accepts a * {@code UriComponentsBuilder} representing the base URL. This is useful * when using MvcUriComponentsBuilder outside the context of processing a * request or to apply a custom baseUrl not matching the current request. * <p><strong>Note:</strong> This method extracts values from "Forwarded" * and "X-Forwarded-*" headers if found. See class-level docs. * @param builder the builder for the base URL; the builder will be cloned * and therefore not modified and may be re-used for further calls. * @param controllerType the controller to build a URI for * @return a UriComponentsBuilder instance (never {@code null}) */ public static UriComponentsBuilder fromController(@Nullable UriComponentsBuilder builder, Class<?> controllerType) { builder = getBaseUrlToUse(builder); // Externally configured prefix via PathConfigurer.. String prefix = getPathPrefix(controllerType); builder.path(prefix); String mapping = getClassMapping(controllerType); builder.path(mapping); return builder; }
private static UriComponentsBuilder fromMethodInternal(@Nullable UriComponentsBuilder builder, Class<?> controllerType, Method method, Object... args) { builder = getBaseUrlToUse(builder); // Externally configured prefix via PathConfigurer.. String prefix = getPathPrefix(controllerType); builder.path(prefix); String typePath = getClassMapping(controllerType); String methodPath = getMethodMapping(method); String path = pathMatcher.combine(typePath, methodPath); builder.path(path); return applyContributors(builder, method, args); }