Search in sources :

Example 1 with ServerRequest

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;
}
Also used : ServerRequest(org.springframework.web.servlet.function.ServerRequest)

Example 2 with 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;
    }
}
Also used : ServerRequest(org.springframework.web.servlet.function.ServerRequest) Nullable(org.springframework.lang.Nullable)

Example 3 with ServerRequest

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;
    }
}
Also used : WebAsyncManager(org.springframework.web.context.request.async.WebAsyncManager) ServerResponse(org.springframework.web.servlet.function.ServerResponse) HandlerFunction(org.springframework.web.servlet.function.HandlerFunction) ServerRequest(org.springframework.web.servlet.function.ServerRequest) Nullable(org.springframework.lang.Nullable)

Aggregations

ServerRequest (org.springframework.web.servlet.function.ServerRequest)3 Nullable (org.springframework.lang.Nullable)2 WebAsyncManager (org.springframework.web.context.request.async.WebAsyncManager)1 HandlerFunction (org.springframework.web.servlet.function.HandlerFunction)1 ServerResponse (org.springframework.web.servlet.function.ServerResponse)1