register method

void register(
  1. Application app
)

Implementation

void register(Application app){
  app.bind('http', (Application app, dynamic params) {
    BaseOptions options = new BaseOptions();

    options.baseUrl = app.config('http_base_url') ?? '';
    options.connectTimeout = app.config('http_connect_timeout') ?? 10000;
    options.receiveTimeout = app.config('http_receive_timeout') ?? 10000;

    Http http = new Http(options);

    http.logEngine = app.make('log');

    if(app.config('http_use_rap') ?? false) {
      http.interceptors.add(Rap.getDioWrapper());
    }

    if(app.config('http_use_log') ?? false) {
      http.interceptors.add(HttpLog.Log.getDioWrapper());
    }
    return http;
  }, share: false);
}