Last active
December 30, 2015 06:28
-
-
Save shikajiro/7789111 to your computer and use it in GitHub Desktop.
AnndroidAnnotationsによる一般的な@rest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EActivity | |
public class HogeActivity{ | |
@Rest WebApi webApi; | |
public void hoge(){ | |
try{ | |
UserJson json = webApi.getUser(1234); | |
return json; | |
}catch(RestClientException e){ | |
//HTTPエラー処理 | |
//RestClientException は非チェック例外 | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Rest(rootUrl = "http://hogehoge.com/hogehoge/", converters = { MappingJacksonHttpMessageConverter.class }, interceptors = {RestInterceptor.class}) | |
public interface WebApi { | |
@Get("user/{id}") | |
UserJson getUser(long id); | |
@Post("user") | |
void postUser(UserJson user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment