From 667e4e753188ec13a8640b3b98d40edd1f991100 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Thu, 8 Feb 2024 12:22:14 +0100 Subject: [PATCH] Implement MatchableHandlerMapping in RouterFunctionMapping See gh-32221 Closes gh-32222 --- .../function/support/RouterFunctionMapping.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java index f67ea7e2e692..600d1db2918f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,8 @@ import org.springframework.web.servlet.function.RouterFunctions; import org.springframework.web.servlet.function.ServerRequest; import org.springframework.web.servlet.handler.AbstractHandlerMapping; +import org.springframework.web.servlet.handler.MatchableHandlerMapping; +import org.springframework.web.servlet.handler.RequestMatchResult; import org.springframework.web.util.pattern.PathPattern; import org.springframework.web.util.pattern.PathPatternParser; @@ -53,7 +55,7 @@ * @author Brian Clozel * @since 5.2 */ -public class RouterFunctionMapping extends AbstractHandlerMapping implements InitializingBean { +public class RouterFunctionMapping extends AbstractHandlerMapping implements InitializingBean, MatchableHandlerMapping { @Nullable private RouterFunction routerFunction; @@ -223,4 +225,9 @@ private void setAttributes(HttpServletRequest servletRequest, ServerRequest requ servletRequest.setAttribute(RouterFunctions.REQUEST_ATTRIBUTE, request); } + @Nullable + @Override + public RequestMatchResult match(HttpServletRequest request, String pattern) { + throw new UnsupportedOperationException("This HandlerMapping uses PathPatterns"); + } }