use of org.springframework.web.method.HandlerMethod in project spring-framework by spring-projects.
the class AbstractHandlerMethodMapping method getCorsConfiguration.
@Override
protected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchange exchange) {
CorsConfiguration corsConfig = super.getCorsConfiguration(handler, exchange);
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
if (handlerMethod.equals(PREFLIGHT_AMBIGUOUS_MATCH)) {
return ALLOW_CORS_CONFIG;
}
CorsConfiguration methodConfig = this.mappingRegistry.getCorsConfiguration(handlerMethod);
corsConfig = (corsConfig != null ? corsConfig.combine(methodConfig) : methodConfig);
}
return corsConfig;
}
use of org.springframework.web.method.HandlerMethod in project spring-framework by spring-projects.
the class AbstractHandlerMethodMapping method createHandlerMethod.
/**
* Create the HandlerMethod instance.
* @param handler either a bean name or an actual handler instance
* @param method the target method
* @return the created HandlerMethod
*/
protected HandlerMethod createHandlerMethod(Object handler, Method method) {
HandlerMethod handlerMethod;
if (handler instanceof String) {
String beanName = (String) handler;
handlerMethod = new HandlerMethod(beanName, getApplicationContext().getAutowireCapableBeanFactory(), method);
} else {
handlerMethod = new HandlerMethod(handler, method);
}
return handlerMethod;
}
use of org.springframework.web.method.HandlerMethod in project spring-framework by spring-projects.
the class MessageReaderArgumentResolverTests method parameterizedMethodArgument.
// SPR-9964
@Test
public void parameterizedMethodArgument() throws Exception {
Method method = AbstractParameterizedController.class.getMethod("handleDto", Identifiable.class);
HandlerMethod handlerMethod = new HandlerMethod(new ConcreteParameterizedController(), method);
MethodParameter methodParam = handlerMethod.getMethodParameters()[0];
SimpleBean simpleBean = resolveValue(methodParam, "{\"name\" : \"Jad\"}");
assertEquals("Jad", simpleBean.getName());
}
use of org.springframework.web.method.HandlerMethod in project spring-framework by spring-projects.
the class ControllerAdviceTests method handle.
private HandlerResult handle(RequestMappingHandlerAdapter adapter, Object controller, String methodName) throws Exception {
Method method = controller.getClass().getMethod(methodName);
HandlerMethod handlerMethod = new HandlerMethod(controller, method);
return adapter.handle(this.exchange, handlerMethod).block(Duration.ZERO);
}
use of org.springframework.web.method.HandlerMethod in project spring-framework by spring-projects.
the class RequestMappingInfoHandlerMappingTests method getHandlerEmptyPathMatch.
@Test
public void getHandlerEmptyPathMatch() throws Exception {
Method expected = on(TestController.class).annot(requestMapping("")).resolveMethod();
ServerWebExchange exchange = get("").toExchange();
HandlerMethod hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block();
assertEquals(expected, hm.getMethod());
exchange = get("/").toExchange();
hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block();
assertEquals(expected, hm.getMethod());
}
Aggregations