Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kodart/Httpzoid
Android REST client library (supports RESTful JSON API)
https://github.com/kodart/Httpzoid
Last synced: 24 days ago
JSON representation
Android REST client library (supports RESTful JSON API)
- Host: GitHub
- URL: https://github.com/kodart/Httpzoid
- Owner: kodart
- Created: 2013-07-09T07:16:51.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-22T11:53:18.000Z (over 11 years ago)
- Last Synced: 2024-08-04T08:01:14.171Z (4 months ago)
- Language: Java
- Homepage:
- Size: 335 KB
- Stars: 82
- Watchers: 18
- Forks: 26
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- my-awesome - Httpzoid - Android REST client library (supports RESTful JSON API) (Java)
README
# Httpzoid - Android REST (JSON) Client
## Overview
Httpzoid is designed to provide a simple way to deal with REST requests.
Requests are asynchronous, callback handler runs in UI thread.## Quick start
This sample will make a post request to the specified url and send User object in JSON format.
```java
Http http = HttpFactory.create(context);
http.post("http://example.com/users")
.data(new User("John"))
.send();
```Request with callbacks.
```java
Http http = HttpFactory.create(context);
http.post("http://example.com/users")
.data(new User("John"))
.handler(new ResponseHandler() {
@Override
public void success(Void ignore, HttpResponse response) {
}@Override
public void error(String message, HttpResponse response) {
}@Override
public void failure(NetworkError error) {
}@Override
public void complete() {
}
}).send();
```Httpzoid works with objects or stream directly
```java
Http http = HttpFactory.create(context);
http.get("http://example.com/users")
.handler(new ResponseHandler() {
@Override
public void success(User[] users, HttpResponse response) {
}
}).send();InputStream input = new FileInputStream("avatar.jpg");
http.post("http://example.com/users/1/avatar")
.data(input)
.handler(new ResponseHandler() {
@Override
public void complete() {
input.close();
}
}).send();
```