use of org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry 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());
}
}
};
}
Aggregations