/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed * @throws AuthenticationException */ public function handle($request, Closure $next) { try { $node = $this->ACSNodeRepository->findByAPIKey($request->header('ApiKey')); } catch (\Exception $e) { throw new AuthenticationException("API Key Invalid"); } //Possibly do some checking here on the access rights for the acs node return $next($request); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response * * @SWG\Post( * path="/acs/node/heartbeat", * tags={"acs"}, * description="Record a heartbeat message, used to determin if the device is online", * @SWG\Response(response="200", description="Heartbeat recorded"), * security={{"api_key": {}}} * ) */ public function heartbeat(Request $request) { $node = $this->ACSNodeRepository->findByAPIKey($request->header('ApiKey')); $this->ACSNodeRepository->logHeartbeat($node->device_id); }