Example #1
0
 /**
  * Returns the DELETE response
  *
  * @param \PSX\Record\RecordInterface $record
  * @return array|\PSX\Record\RecordInterface
  */
 protected function doDelete($record)
 {
     $this->rateService->delete((int) $this->getUriFragment('rate_id'));
     return array('success' => true, 'message' => 'Rate successful deleted');
 }
Example #2
0
 public function onLoad()
 {
     parent::onLoad();
     // get request ip
     $remoteIp = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     // load app and user
     $this->app = $this->getApp($this->appId);
     $this->user = $this->getUser($this->userId);
     // check rate limit
     if ($this->rateService->hasExceeded($remoteIp, $this->context->get('fusio.routeId'), $this->app)) {
         throw new StatusCode\ClientErrorException('Rate limit exceeded', 429);
     }
     // log request
     $this->logId = $this->apiLogger->log($this->context->get('fusio.routeId'), $this->appId, $this->userId, $remoteIp, $this->request);
 }
Example #3
0
 /**
  * Returns the POST response
  *
  * @param \PSX\Record\RecordInterface $record
  * @return array|\PSX\Record\RecordInterface
  */
 protected function doPost($record)
 {
     $this->rateService->create($record->priority, $record->name, $record->rateLimit, $record->timespan, $record->allocation);
     return array('success' => true, 'message' => 'Rate successful created');
 }