io.femo.http.Environment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-jdk7 Show documentation
Show all versions of http-jdk7 Show documentation
An easy to use HTTP API, that supports synchronous and asynchronous execution of HTTP request.
On android only asynchronous driver is supported.
This library has been backported to jdk 7 to retain compatibility with android!
The newest version!
package io.femo.http;
import io.femo.http.middleware.EnvironmentReplacerMiddleware;
import io.femo.support.jdk7.Supplier;
/**
* Created by felix on 7/2/16.
*/
public abstract class Environment implements Driver {
public abstract boolean has(String variable);
public abstract EnvironmentReplacerMiddleware.HttpSupplier get(String key);
public abstract Environment set(String name, EnvironmentReplacerMiddleware.HttpSupplier value);
public Environment set(String name, final String value) {
return set(name, new EnvironmentReplacerMiddleware.HttpSupplier() {
@Override
public String get(HttpRequest req, HttpResponse res) {
return value;
}
});
}
public Environment set(String name, final Supplier value) {
return set(name, new EnvironmentReplacerMiddleware.HttpSupplier() {
@Override
public String get(HttpRequest req, HttpResponse res) {
return value.get();
}
});
}
}