示例#1
0
     } else {
         if (isset($post['title'], $post['artist'], $post['rating'])) {
             if (!empty($post['title']) && !empty($post['artist']) && !empty($post['rating'])) {
                 $api->postSingle($post['title'], $_POST['artist'], $_POST['rating'], $conn);
             }
         } else {
             http_response_code(400);
         }
     }
     break;
 case "PUT":
     if ($id != null) {
         if ($input != null) {
             if (isset($input->title, $input->artist, $input->rating)) {
                 if (!empty($input->title) && !empty($input->artist) && !empty($input->rating)) {
                     echo $api->putSingle($input->title, $input->artist, $input->rating, $id, $conn);
                     break;
                 }
             }
             http_response_code(400);
         } else {
             echo json_encode(['geen input']);
             http_response_code(400);
         }
     } else {
         http_response_code(405);
     }
     break;
 case "OPTIONS":
     $options = $id == null ? "GET,POST,OPTIONS" : "GET,PUT,DELETE,OPTIONS";
     header("Allow: " . $options);