use of cn.taketoday.http.server.RequestPath in project today-infrastructure by TAKETODAY.
the class WebContentInterceptor method beforeProcess.
@Override
public boolean beforeProcess(RequestContext context, Object handler) {
checkRequest(context);
RequestPath path = context.getLookupPath();
if (ObjectUtils.isNotEmpty(cacheControlMappings)) {
CacheControl control = lookupCacheControl(path);
if (control != null) {
if (log.isTraceEnabled()) {
log.trace("Applying {}", control);
}
applyCacheControl(context, control);
return true;
}
}
if (ObjectUtils.isNotEmpty(cacheMappings)) {
Integer cacheSeconds = lookupCacheSeconds(path);
if (cacheSeconds != null) {
if (log.isTraceEnabled()) {
log.trace("Applying cacheSeconds {}", cacheSeconds);
}
applyCacheSeconds(context, cacheSeconds);
return true;
}
}
prepareResponse(context);
return true;
}
use of cn.taketoday.http.server.RequestPath in project today-framework by TAKETODAY.
the class RequestContext method getLookupPath.
/**
* @since 4.0
*/
public final RequestPath getLookupPath() {
RequestPath lookupPath = this.lookupPath;
if (lookupPath == null) {
lookupPath = RequestPath.parse(getRequestPath(), getContextPath());
this.lookupPath = lookupPath;
}
return lookupPath;
}
use of cn.taketoday.http.server.RequestPath in project today-framework by TAKETODAY.
the class PathVariableMapMethodArgumentResolverTests method resolveArgument.
@Test
public void resolveArgument() throws Throwable {
applyTemplateVars();
Map<String, String> uriTemplateVars = new HashMap<>();
uriTemplateVars.put("name1", "value1");
uriTemplateVars.put("name2", "value2");
RequestPath requestPath = RequestPath.parse("/mock/value1/value2", null);
PathPattern pathPattern = PathPatternParser.defaultInstance.parse("/mock/{name1}/{name2}");
HandlerMatchingMetadata matchingMetadata = new HandlerMatchingMetadata(new Object(), "/mock", requestPath, pathPattern, PathPatternParser.defaultInstance);
webRequest.setMatchingMetadata(matchingMetadata);
Object result = resolver.resolveArgument(webRequest, paramMap);
assertThat(result).isEqualTo(uriTemplateVars);
}
use of cn.taketoday.http.server.RequestPath in project today-framework by TAKETODAY.
the class UrlFilenameViewController method extractOperableUrl.
/**
* Extract a URL path from the given request,
* suitable for view name extraction.
*
* @param request current HTTP request
* @return the URL to use for view name extraction
*/
protected String extractOperableUrl(RequestContext request) {
RequestPath lookupPath = request.getLookupPath();
String path = lookupPath.pathWithinApplication().value();
path = removeSemicolonContent ? WebUtils.removeSemicolonContent(path) : path;
return path;
}
use of cn.taketoday.http.server.RequestPath in project today-framework by TAKETODAY.
the class WebContentInterceptor method beforeProcess.
@Override
public boolean beforeProcess(RequestContext request, Object handler) {
checkRequest(request);
RequestPath path = request.getLookupPath();
if (ObjectUtils.isNotEmpty(cacheControlMappings)) {
CacheControl control = lookupCacheControl(path);
if (control != null) {
if (log.isTraceEnabled()) {
log.trace("Applying {}", control);
}
applyCacheControl(request, control);
return true;
}
}
if (ObjectUtils.isNotEmpty(cacheMappings)) {
Integer cacheSeconds = lookupCacheSeconds(path);
if (cacheSeconds != null) {
if (log.isTraceEnabled()) {
log.trace("Applying cacheSeconds {}", cacheSeconds);
}
applyCacheSeconds(request, cacheSeconds);
return true;
}
}
prepareResponse(request);
return true;
}
Aggregations