/**
  * Queries database for given ip and returns result as json encoded string.
  *
  * @param string $ip
  * @param array $optionsInput
  * @return bool
  */
 public function __invoke($ip, $optionsInput = [])
 {
     // get record from city-db:
     $cityDbDomain = new CityDbDomain($this->app);
     $record = $cityDbDomain->getRecord($ip);
     // prepare api options from request:
     $apiOptionsDomain = new ApiOptionsDomain($this->app);
     $options = $apiOptionsDomain->parseOptions($optionsInput);
     // handle response:
     $apiRequestResponder = new ApiRequestResponder($this->app);
     if (empty($record)) {
         $apiRequestResponder->notFound();
         return false;
     }
     if ($options['type'] === 'full') {
         $apiRequestResponder->set('record', $record);
         $apiRequestResponder->full();
     } else {
         $recordDomain = new RecordDomain($this->app);
         $recordShort = $recordDomain->shortenRecord($record, $options['lang']);
         $apiRequestResponder->set('record', $recordShort);
         $apiRequestResponder->short();
     }
     return true;
 }
 /**
  * Loads geoip-data for client ip and displays homepage.
  */
 public function __invoke()
 {
     $cityDbDomain = new CityDbDomain($this->app);
     $recordDomain = new RecordDomain($this->app);
     $record = $cityDbDomain->getRecord($_SERVER['REMOTE_ADDR']);
     $recordShort = [];
     if (!empty($record)) {
         $recordShort = $recordDomain->shortenRecord($record, $this->app->defaultLang);
     }
     $responder = new ShowHomepageResponder($this->app);
     $responder->set('record', $recordShort);
     $responder->home();
 }