Exemplo n.º 1
0
        $app->response->status(400);
    } else {
        $app->response->status(201);
        $tags = Postmortem::get_tags_for_event($id);
        if ($tags["status"] == Postmortem::ERROR) {
            $app->response->status(404);
            return;
        } else {
            $output = json_encode($tags["values"]);
            echo str_replace("\\/", "/", $output);
        }
    }
});
$app->delete('/events/:event_id/tags/:tag_id', function ($event_id, $tag_id) use($app) {
    header("Content-Type: application/json");
    $res = Postmortem::delete_tag($tag_id, $event_id);
    if ($res["status"] == Postmortem::ERROR) {
        $app->response->status(500);
        echo json_encode($res["error"]);
    } else {
        $app->response->status(204);
    }
});
$app->get('/ping', function () use($app) {
    header("Content-Type: application/json");
    echo json_encode(array('status' => 'ok'));
});
// Handle custom static assets.
// Javascript first then CSS.
$app->get('/features/:feature/js/:path', function ($feature, $path) use($app) {
    // read the file if it exists. Then serve it back.
Exemplo n.º 2
0
 /**
  * delete tags belonging to a certain event to the database
  *
  * @param $event_id - numeric ID of the event to delete for
  * @param $conn - a PDO connection object
  *
  * @returns ( "status" => self::OK ) on success
  * or ( "status" => self::ERROR, "error" => "an error message" ) on failure
  */
 static function delete_tags_for_event($event_id, $conn = null)
 {
     $res = Postmortem::get_tags_for_event($event_id);
     if ($res == Persistence::ERROR) {
         return $res;
     }
     $tags = $res['values'];
     foreach ($tags as $tag) {
         $res = Postmortem::delete_tag($tag['id'], $event_id, $conn);
         if ($res['status'] == Persistence::ERROR) {
             break;
         }
     }
     return $res;
 }