https://github.com/satorufujiwara/lighthttp
Lightweitht HTTP client for Android
https://github.com/satorufujiwara/lighthttp
Last synced: 3 months ago
JSON representation
Lightweitht HTTP client for Android
- Host: GitHub
- URL: https://github.com/satorufujiwara/lighthttp
- Owner: satorufujiwara
- License: apache-2.0
- Created: 2015-09-22T07:42:14.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-10-17T15:01:24.000Z (over 10 years ago)
- Last Synced: 2023-03-02T09:11:46.277Z (over 3 years ago)
- Language: Java
- Size: 212 KB
- Stars: 42
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - LightHTTP
README
lighthttp
===
[](https://www.apache.org/licenses/LICENSE-2.0)
[](https://android-arsenal.com/details/1/2543)
[](https://bintray.com/satorufujiwara/maven/lighthttp/_latestVersion)
Lightweitht HTTP client for Android.
# Features
* Simple HTTP client.
* Depends on Android(HttpUrlConnection) only.
* Execute asynchronously or can use with RxJava.
* Convert request and response.
# Usage
Get a url.
```java
LightHttpClient httpClient = new LightHttpClient();
Request request = httpClient.newRequest()
.url("https://api.github.com/users/satorufujiwara/repos")
.get()
.build();
Response response = httpClient.newCall(request).execute();
String body = response.getBody();
```
## Converter
Convert response to java object.
```java
httpClient.setConverterProvider(new GsonConverterProvider());
Response response = httpClient.newCall(request, Repos.class).execute();
Repos body = response.getBody();
```
Post json object.
```java
httpClient.setConverterProvider(new GsonConverterProvider());
Item obj = new Item();
Request request = httpClient.newRequest()
.url(url)
.post(obj, Item.class)
.build();
```
## Executor
Execute asynchronously.
```java
httpClient.newCall(request, Repos.class)
.executeOn(AsyncExecutor.provide())
.executeAsync(new AsyncCallback() {
@Override
public void onResult(Response response, Throwable e) {
}
});
```
Use with [RxJava](https://github.com/ReactiveX/RxJava).
```java
httpClient.newCall(request, Repos.class)
.executeOn(RxExecutor.provide())
.asObservable()
.subscribeOn(Schedulers.io())
.subscribe();
```
# Gradle
```groovy
dependencies {
compile 'jp.satorufujiwara:lighthttp:0.1.1'
}
```
## Converter
Gson
```groovy
compile 'jp.satorufujiwara:lighthttp-gson:0.1.1'
```
## Executor
Async
```groovy
compile 'jp.satorufujiwara:lighthttp-async:0.1.1'
```
RxJava
```groovy
compile 'jp.satorufujiwara:lighthttp-rx:0.1.1'
```
# Milestone
- [ ] Multipart request body.
- [ ] Jackson converter.
- [ ] Jsonic converter.
- [ ] Sample app.
- [ ] Testing.
# Developed By
Satoru Fujiwara (satorufujiwara)
* Twitter [satorufujiwara](https://twitter.com/satorufujiwara)
* holly.wist@gmail.com
Other Projects
* [recyclerview-binder](https://github.com/satorufujiwara/recyclerview-binder)
* Android Library for RecyclerView to manage order of items and multiple view types.
* [material-scrolling](https://github.com/satorufujiwara/material-scrolling)
* Android library for material scrolling techniques.
License
-------
Copyright 2015 Satoru Fujiwara
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.