Source点

  • 待补充

Http路由

  • 待补充

其他Demo

  1. let client = Retrofit.getBuilder()
  2. .setConfig<RetrofitConfig>( { /** config, you can use retrofit config or axios config */ } )
  3. .addInterceptor( /** your interceptor */ )
  4. .setErrorHandler( /** define your error handler */ )
  5. .build();
  6. // This is the part of define any interface what you need.
  7. @HTTP( "/testing" )
  8. @Headers( [ "Cache-Control: no-store" ] )
  9. class TestingClient {
  10. @GET( "/demo1/:callByWho/:when" )
  11. public demo1( @Path( "callByWho" ) name: string, @Path( "when" ) time: number ): RetrofitPromise<string> & void {
  12. }
  13. @POST( "/demo2/:file" )
  14. public demo2( @Path( "file" ) file: string, @Header( "cookie" ) val: string, @Config localConfig: AxiosConfig ): RetrofitPromise<string> & void {
  15. }
  16. }
  17. // The final step, create your client.
  18. export let testingClient = client.create( TestingClient );
  19. // When you are calling this method, it is a http call actually.
  20. testingClient.demo1( "itfinally", Date.now() ).then( response => {
  21. // any code
  22. } ).catch( reason => {
  23. // any code
  24. } );
  25. // And you can also get axios instance.
  26. let axios: AxiosInstance = client.getEngine();

参考书目