Request against httpbin which was installed on localhost:
- HTTP / HTTPS method support
- GET, POST, PUT, DELETE, OPTIONS, HEAD, TRACE request support
- Real logging of request and response
- Builders for fast and easy request execution
- Automatic request and response parsing
- Integrated Object, URL-Encoded & Multipart-Body support
- Custom and predefined interceptors
- Powerful authorization strategy
- Lambda support
- Fully customizable cookie store
- Host and SSL trust strategy
- Easy proxy strategy
- Android support
- GroundWork ServiceResult support
- Faster than other HttpClient-Frameworks (such as httpComponents,okhttp)
- Gson and XStream support
- OAuth2 support
- Annotation application structure
- URL placeholder support
- Advanced cache strategy (coming soon)
- GroundWork Server-Security support (coming soon)
- HAL support (coming soon)
<dependency>
<groupId>ch.viascom.groundwork</groupId>
<artifactId>foxhttp</artifactId>
<version>1.3.6</version>
</dependency>
compile 'ch.viascom.groundwork:foxhttp:1.3.6'
To run this example you need to add Gson to your dependency management!
// Define Http-Client and set parser for serialization/deserialization
FoxHttpClient foxHttpClient = new FoxHttpClientBuilder(new GsonParser()).build();
// Define a System-Out logger on DEBUG level
foxHttpClient.setFoxHttpLogger(new SystemOutFoxHttpLogger(true, "FoxHttp-Logger", FoxHttpLoggerLevel.DEBUG));
// Create and Execute GET Request
FoxHttpResponse response = new FoxHttpRequestBuilder("http://httpbin.org/get?search=Viascom", RequestType.GET, foxHttpClient).buildAndExecute();
// Deserialization response
GetResponse object = response.getParsedBody(GetResponse.class);
// Print result
System.out.println("Parsed-Output: " + object);
To deserialize the response you need the following model:
public class GetResponse implements Serializable {
public HashMap<String, String> args;
public HashMap<String, String> headers;
public String origin;
public String url;
@Override
public String toString() {
return "GetResponse{" +
"args=" + args +
", headers=" + headers +
", origin='" + origin + '\'' +
", url='" + url + '\'' +
'}';
}
}