You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
// default http 80 https 443Req.init(context,serialier);// set http portReq.init(context,3000,serialier);// set https portReq.init(context,3000,5000,serialier)// set base url example for https://api.somedomain.comReq.base("https://ithot.org");// distinguish different users requestReq.prefix("user_id");// if true log response default falseReq.debug(true);// http lifecycle hooksReq.hook(newIHTTPHook(){// no network call this hook@Overridepublicvoiddisconnected(Contextcontext) { }// you can set common headers@OverridepublicList<Header>headers() { }// before request call this hook, you can display a dialog@Overridepublicvoidpre(Contextcontext) { }// request done call this hook, you can dismiss a dialog@Overridepublicvoidpost(Contextcontext) { }// abnormal response call this hook@Overridepublicvoidfail(Header[]headers,Stringresponse,Contextcontext) { }});
custom json serializer
publicclassSerializerextendsJSONSerializer {// you can use any serialization library such as Gson Fastjson etc example belowprivateGsongson =newGson();@OverridepublicObjectparse(Stringjson,Typetype) {returngson.fromJson(json,type); }@OverridepublicStringstringify(Objectobject) {returngson.toJson(object); }}Req.init(context,newSerializer());