2016년 12월 27일 화요일

[Retrofit] Retrofit 을 이용한 Restful Service 만들기

public interface RestService {
    @POST("/update/user")
    Call<SsUser> updateUser(@Body SsUser user);
    @POST("/find/user")
    Call<SsUser> findUser(@Query("sourceType") String sourceType, @Query("sourceId") String sourceId);
    @GET("/find/{tableName}")
    <T> Call<?> find(@Path("tableName") String tableName, @Query("id") String id);
    @GET("/list/{tableName}")
    <T> Call<List<?>> list(@Path("tableName") String tableName, @Body PageEntity page);
    @POST("/push/history")
    Call<BaseEntity> pushHistory(@Body List<SsLogging> loggings);}

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

https://square.github.io/retrofit/

Rest 서비스를 읽어드리는 Client 소스가 있어보인다 @.@
소스가 점점 직관적이고 단순화 되는구나. 멋져~~
요근래 알게된 오픈소스중 젤루 멋지다~~~

댓글 없음:

댓글 쓰기