/** * @return bool */ public function send() { $this->sendHeader(); switch ($this->resType) { case 'json': \Flight::json($this->data, $this->resCode, true, 'utf8', $this->jsonOptions); return false; case 'jsonp': \Flight::jsonp($this->data, $this->jsonpCallback, $this->resCode, true, 'utf8', $this->jsonOptions); return false; case 'view': getView()->render($this->view, $this->data); return false; case 'filter': return true; } return false; }
$templatedata['ip'] = $request->ip; $templatedata['geoinfo'] = Flight::get('geoinfo'); $templatedata['meta_description'] = Flight::get('meta_description'); // evaluate the query string (if any) if (isset($request->query->js)) { $templatedata['js'] = $request->query->js; } else { $templatedata['js'] = Flight::get('js'); } if (isset($request->query->maptype)) { $templatedata['maptype'] = $request->query->maptype; } else { $templatedata['maptype'] = Flight::get('maptype'); } Flight::render('partials/iframe_insert.php', $templatedata, 'iframe_insert'); Flight::render('default.php', $templatedata); }); // api to look up an ip (returns jsonp) // http://somedomain.com/api/ip/24.105.250.46?cb=callback Flight::route('GET /api/ip/@ip', function ($ip) { Flight::checkIP($ip); Flight::jsonp(array('ip' => Flight::get('ip'), 'city' => Flight::get('city'), 'region' => Flight::get('region'), 'areaCode' => Flight::get('areaCode'), 'dmaCode' => Flight::get('dmaCode'), 'countryCode' => Flight::get('countryCode'), 'continentCode' => Flight::get('continentCode'), 'latitude' => Flight::get('latitude'), 'longitude' => Flight::get('longitude'), 'regionCode' => Flight::get('regionCode'), 'regionName' => Flight::get('regionName')), 'cb'); }); // place any other dynamic routes here // everything else (static folder) Flight::route('GET /*', function () { $fpath = Flight::request()->url; Flight::getStaticFile($fpath); }); // Now Set It Off! Flight::start();