use of com.github.dreamhead.moco.resource.Resource in project moco by dreamhead.
the class DynamicResponseHandlerFactory method fileResource.
private Resource fileResource(final String name, final FileContainer fileContainer) {
if (fileContainer.isForTemplate()) {
if ("version".equalsIgnoreCase(name)) {
return version(fileContainer.asTemplateResource());
}
return fileContainer.asTemplateResource(name);
}
TextContainer filename = fileContainer.getName();
if (filename.isRawText()) {
return asResource(name, fileContainer);
}
if (filename.isForTemplate()) {
Optional<Charset> charset = fileContainer.getCharset();
Resource resource = filename.asTemplateResource();
return asResource(name, resource, charset);
}
throw new IllegalArgumentException(format("unknown file container:[%s]", fileContainer));
}
use of com.github.dreamhead.moco.resource.Resource in project moco by dreamhead.
the class ContentHandler method apply.
@Override
public ResponseHandler apply(final MocoConfig config) {
ResponseHandler handler = super.apply(config);
if (handler != this) {
return handler;
}
Resource appliedReosurce = this.resource.apply(config);
if (appliedReosurce != this.resource) {
return new ContentHandler((ContentResource) appliedReosurce);
}
return this;
}
Aggregations