1 Star 0 Fork 730

simon / forest

forked from 捣鼓 / forest 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CALLBACK.md 867 Bytes
一键复制 编辑 原始数据 按行查看 历史
骏码 提交于 2017-04-21 18:58 . new repository

Forest 使用文档

回调方法

OnSuccess - 请求成功:


@Request(
    url = "http://dwz.cn/create.php",
    type = "post",
    dataType = "json"
)
String testOnSuccess(@DataParam("url") String url, OnSuccess<Map> onSuccess);

...

client.testOnSuccess("https://github.com/mySingleLive", new OnSuccess<Map>() {
    public void onSuccess(Map data, ForestRequest request, ForestResponse response) {
        System.out.println(data);
        assertNotNull(data);
        assertEquals(data.get("status"), 0);
    }
});

OnError - 请求失败:


@Request(url = "http://this_is_a_error_address", timeout = 10)
String testError(OnError onError);

...

client.testError(new OnError() {
    public void onError(ForestRuntimeException ex, ForestRequest request) {
        assertNotNull(ex);
        assertNotNull(request);
    }
});

Java
1
https://gitee.com/simon_kly/forest.git
git@gitee.com:simon_kly/forest.git
simon_kly
forest
forest
master

搜索帮助