Android網絡操作解決方案:Wasp
Wasp是緊湊、完整、易于使用、集所有功能于一身的Android網絡解決方案。 Wasp基本上是對volley網絡堆棧進行了接口式改造,但提供了更多的功能如MOCK,證書管理,cookie管理等。基本上它提供了所有需要的一個完整解決方案。
Wasp 使用的第三庫:
- Volley
- Gson
- OkHttp
Wasp 提供
- 易于實現
- 模擬網絡調用
- 易于使用的圖片管理
- Request Interceptor to add attributes (query params, headers, retry policy) to each call
- Call based headers
- Call based endpoint url
- Call based retry policy
- Cookie management
- Certificate management
- Easy-in-use auth token management

用法
Create your service class
Create a service interface and define all your network calls
@GET,@DELETE,@POST,@PUT can be used for http method.
@Path is used for replacement for specific words in the url.
public interface GitHubService { @GET("/repos/{user}/{repo}") void fetchRepo( @Path("user") String user, @Path("repo") String repo, CallBack<List<Repo>> callBack ); @POST("/repos/{user}/{repo}") void addRepo( @Path("user") String user, @Path("repo") String repo, CallBack<Repo> callBack ); }
service.fetchRepo("admin","wasp",callback); //url will be ENDPOINT/repos/admin/wasp
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!