use of org.springframework.web.servlet.resource.GzipResourceResolver in project jphp by jphp-compiler.
the class PWebServer method _makeHandlers.
protected WebServerConfig.Handlers _makeHandlers() {
return new WebServerConfig.Handlers() {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
for (ArrayMemory handler : staticHandlers) {
Memory path = handler.valueOfIndex("path");
ResourceHandlerRegistration registration;
if (path.isArray()) {
registration = registry.addResourceHandler(path.toValue(ArrayMemory.class).toStringArray());
} else {
registration = registry.addResourceHandler(path.toString());
}
Memory cachePeriod = handler.valueOfIndex("cachePeriod");
registration.setCachePeriod(cachePeriod.isNull() ? null : cachePeriod.toInteger());
Memory location = handler.valueOfIndex("location");
if (location.isArray()) {
registration.addResourceLocations(location.toValue(ArrayMemory.class).toStringArray());
} else {
registration.addResourceLocations(location.toString());
}
ResourceChainRegistration chain = registration.resourceChain(handler.valueOfIndex("cache").toBoolean());
if (handler.valueOfIndex("gzip").toBoolean()) {
chain.addResolver(new GzipResourceResolver());
}
chain.addResolver(new PathResourceResolver());
}
}
};
}
use of org.springframework.web.servlet.resource.GzipResourceResolver in project tutorials by eugenp.
the class MvcConfig method addResourceHandlers.
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// For examples using Spring 4.1.0
if ((env.getProperty("resource.handler.conf")).equals("4.1.0")) {
registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver()).addResolver(new PathResourceResolver());
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/", "classpath:/other-resources/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver());
registry.addResourceHandler("/files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver());
registry.addResourceHandler("/other-files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver());
} else // For examples using Spring 4.0.7
if ((env.getProperty("resource.handler.conf")).equals("4.0.7")) {
registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/", "classpath:/other-resources/");
registry.addResourceHandler("/files/**").addResourceLocations("file:/Users/Elena/");
}
}
Aggregations