Beispiel #1
0
 /**
  * @param Route $route
  * @param string $pathUrl
  * @return Route|null
  */
 protected function matchRule(Route $route, $pathUrl)
 {
     $activeRoute = null;
     $regexp = $this->routeService->makeRegExp($route);
     if (preg_match('~^' . $regexp . '$~Uiu', $pathUrl, $values)) {
         $filterValues = array_filter(array_keys($values), 'is_string');
         $matches = array_intersect_key($values, array_flip($filterValues));
         $activeRoute = $route->setMatches($matches);
     }
     return $activeRoute;
 }
Beispiel #2
0
    $response = RouteService::updateRoute($objRoute);
    Utils::echoResponse($response);
});
$app->delete('/routes', function () use($app) {
    //Check authentication
    $rs = UserService::checkAuthentication($app->request->headers->get('apiKey'));
    if ($rs["status"] != SUCCESS) {
        Utils::echoResponse($rs);
        return;
    }
    //Get a user sent from client and convert it to a json object
    $jsonRoute = $app->request->getBody();
    $objRoute = json_decode($jsonRoute, true);
    $objRoute['routeDesigner']['designerId'] = $rs['data']->id;
    //So even with a valid apiKey, the designer can access her own resources only
    $response = RouteService::deleteRoute($objRoute);
    Utils::echoResponse($response);
});
//RESTful for Media
$app->post('/media', function () use($app) {
    //Check authentication
    $rs = UserService::checkAuthentication($app->request->headers->get('apiKey'));
    if ($rs["status"] != SUCCESS) {
        Utils::echoResponse($rs);
        return;
    }
    //Get a user sent from client and convert it to a json object
    $jsonMedia = $app->request->getBody();
    $objMedia = json_decode($jsonMedia, true);
    $objMedia['mediaDesigner']['designerId'] = $rs['data']->id;
    //So even with a valid apiKey, the designer can access her own resources only