Retrofit项目 - Android和Java的类型安全的HTTP客户端

A type-safe HTTP client for Android and Java

官网:Retrofit

Retrofit turns your HTTP API into a Java interface.

public interface GitHubService {   
    @GET("users/{user}/repos")   
    Call> listRepos(@Path("user") String user); 
}

The Retrofit class generates an implementation of the GitHubService interface.

Retrofit retrofit = new Retrofit.Builder()     
	.baseUrl("https://api.github.com/")     
	.build(); 
GitHubService service = retrofit.create(GitHubService.class);

Each Call from the created GitHubService can make a synchronous or asynchronous HTTP request to the remote webserver.

Call> repos = service.listRepos("octocat");

Use annotations to describe the HTTP request:

  • URL parameter replacement and query parameter support
  • Object conversion to request body (e.g., JSON, protocol buffers)
  • Multipart request body and file upload

你可能感兴趣的:(Android开发技术,retrofit,android,java,http)