
net.anthavio.httl.HttlExecutionChain Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hatatitla Show documentation
Show all versions of hatatitla Show documentation
Compact but tweakable REST client library you have been dreaming of
The newest version!
package net.anthavio.httl;
import java.io.IOException;
import java.util.List;
/**
*
* @author martin.vanek
*
*/
public interface HttlExecutionChain {
public HttlResponse next(HttlRequest request) throws IOException;
/**
* Standard HttlSender backed implementation with List of HttlExecutionFilters
*
* @author martin.vanek
*
*/
public static class SenderExecutionChain implements HttlExecutionChain {
private final List fiters;
private final HttlSender sender;
private int index = 0;
public SenderExecutionChain(List fiters, HttlSender sender) {
this.fiters = fiters;
this.sender = sender;
}
public HttlResponse next(HttlRequest request) throws IOException {
if (index < fiters.size()) {
return fiters.get(index++).filter(request, this);
} else {
return sender.doExecute(request); //last
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy