use of org.springframework.web.servlet.function.ServerRequest in project spring-framework by spring-projects.
the class HandlerFunctionAdapter method getServerRequest.
private ServerRequest getServerRequest(HttpServletRequest servletRequest) {
ServerRequest serverRequest = (ServerRequest) servletRequest.getAttribute(RouterFunctions.REQUEST_ATTRIBUTE);
Assert.state(serverRequest != null, () -> "Required attribute '" + RouterFunctions.REQUEST_ATTRIBUTE + "' is missing");
return serverRequest;
}
use of org.springframework.web.servlet.function.ServerRequest in project spring-framework by spring-projects.
the class RouterFunctionMapping method getHandlerInternal.
@Override
@Nullable
protected Object getHandlerInternal(HttpServletRequest servletRequest) throws Exception {
if (this.routerFunction != null) {
ServerRequest request = ServerRequest.create(servletRequest, this.messageConverters);
HandlerFunction<?> handlerFunction = this.routerFunction.route(request).orElse(null);
setAttributes(servletRequest, request, handlerFunction);
return handlerFunction;
} else {
return null;
}
}
use of org.springframework.web.servlet.function.ServerRequest in project spring-framework by spring-projects.
the class HandlerFunctionAdapter method handle.
@Nullable
@Override
public ModelAndView handle(HttpServletRequest servletRequest, HttpServletResponse servletResponse, Object handler) throws Exception {
WebAsyncManager asyncManager = getWebAsyncManager(servletRequest, servletResponse);
ServerRequest serverRequest = getServerRequest(servletRequest);
ServerResponse serverResponse;
if (asyncManager.hasConcurrentResult()) {
serverResponse = handleAsync(asyncManager);
} else {
HandlerFunction<?> handlerFunction = (HandlerFunction<?>) handler;
serverResponse = handlerFunction.handle(serverRequest);
}
if (serverResponse != null) {
return serverResponse.writeTo(servletRequest, servletResponse, new ServerRequestContext(serverRequest));
} else {
return null;
}
}
Aggregations