Search in sources :

Example 1 with PathMatchInfo

use of cn.taketoday.web.util.pattern.PathMatchInfo in project today-infrastructure by TAKETODAY.

the class HandlerMatchingMetadata method getPathMatchInfo.

public PathMatchInfo getPathMatchInfo() {
    PathMatchInfo pathMatchInfo = this.pathMatchInfo;
    if (pathMatchInfo == null) {
        pathMatchInfo = getBestMatchingPattern().matchAndExtract(requestPath);
        if (pathMatchInfo == null) {
            pathMatchInfo = PathMatchInfo.EMPTY;
        }
        this.pathMatchInfo = pathMatchInfo;
    }
    return pathMatchInfo;
}
Also used : PathMatchInfo(cn.taketoday.web.util.pattern.PathMatchInfo)

Example 2 with PathMatchInfo

use of cn.taketoday.web.util.pattern.PathMatchInfo in project today-framework by TAKETODAY.

the class HandlerMatchingMetadata method getPathMatchInfo.

public PathMatchInfo getPathMatchInfo() {
    PathMatchInfo pathMatchInfo = this.pathMatchInfo;
    if (pathMatchInfo == null) {
        pathMatchInfo = getBestMatchingPattern().matchAndExtract(requestPath);
        if (pathMatchInfo == null) {
            pathMatchInfo = PathMatchInfo.EMPTY;
        }
        this.pathMatchInfo = pathMatchInfo;
    }
    return pathMatchInfo;
}
Also used : PathMatchInfo(cn.taketoday.web.util.pattern.PathMatchInfo)

Example 3 with PathMatchInfo

use of cn.taketoday.web.util.pattern.PathMatchInfo in project today-framework by TAKETODAY.

the class AnnotationWebSocketDispatcher method afterHandshake.

@Override
public void afterHandshake(RequestContext context, WebSocketSession session) throws Throwable {
    context.setAttribute(WebSocketSession.WEBSOCKET_SESSION_KEY, session);
    // invoke after handshake callback
    socketHandler.afterHandshake(context);
    if (socketHandler.containsPathVariable) {
        // for path variables handling
        PathPattern pathPattern = socketHandler.pathPattern;
        RequestPath parsedRequestPath = context.getLookupPath();
        PathMatchInfo pathMatchInfo = pathPattern.matchAndExtract(parsedRequestPath);
        Assert.state(pathMatchInfo != null, "Path match error");
        Map<String, String> uriVariables = pathMatchInfo.getUriVariables();
        session.setAttribute(WebSocketSession.URI_TEMPLATE_VARIABLES, uriVariables);
    }
}
Also used : RequestPath(cn.taketoday.http.server.RequestPath) PathMatchInfo(cn.taketoday.web.util.pattern.PathMatchInfo) PathPattern(cn.taketoday.web.util.pattern.PathPattern)

Example 4 with PathMatchInfo

use of cn.taketoday.web.util.pattern.PathMatchInfo in project today-infrastructure by TAKETODAY.

the class AnnotationWebSocketDispatcher method afterHandshake.

@Override
public void afterHandshake(RequestContext context, WebSocketSession session) throws Throwable {
    context.setAttribute(WebSocketSession.WEBSOCKET_SESSION_KEY, session);
    // invoke after handshake callback
    socketHandler.afterHandshake(context);
    if (socketHandler.containsPathVariable) {
        // for path variables handling
        PathPattern pathPattern = socketHandler.pathPattern;
        RequestPath parsedRequestPath = context.getLookupPath();
        PathMatchInfo pathMatchInfo = pathPattern.matchAndExtract(parsedRequestPath);
        Assert.state(pathMatchInfo != null, "Path match error");
        Map<String, String> uriVariables = pathMatchInfo.getUriVariables();
        session.setAttribute(WebSocketSession.URI_TEMPLATE_VARIABLES, uriVariables);
    }
}
Also used : RequestPath(cn.taketoday.http.server.RequestPath) PathMatchInfo(cn.taketoday.web.util.pattern.PathMatchInfo) PathPattern(cn.taketoday.web.util.pattern.PathPattern)

Aggregations

PathMatchInfo (cn.taketoday.web.util.pattern.PathMatchInfo)4 RequestPath (cn.taketoday.http.server.RequestPath)2 PathPattern (cn.taketoday.web.util.pattern.PathPattern)2