Deduplicate API GET check into single file

This commit is contained in:
Marcus Hill
2022-04-14 20:05:15 +01:00
parent b4f2fdd03d
commit 17f97ff7bc
8 changed files with 15 additions and 49 deletions

View File

@@ -1,13 +1,7 @@
<?php <?php
require('../validate_api_key.php'); require('../validate_api_key.php');
if($_SERVER['REQUEST_METHOD'] !== "GET"){ require('../require_get_method.php');
header("HTTP/1.1 405 Method Not Allowed");
$return_arr['success'] = "False";
$return_arr['message'] = "Can only send GET requests to this endpoint.";
echo json_encode($return_arr);
exit();
}
// Asset via ID (single) // Asset via ID (single)
if(isset($_GET['asset_id'])){ if(isset($_GET['asset_id'])){

View File

@@ -1,13 +1,7 @@
<?php <?php
require('../validate_api_key.php'); require('../validate_api_key.php');
if($_SERVER['REQUEST_METHOD'] !== "GET"){ require('../require_get_method.php');
header("HTTP/1.1 405 Method Not Allowed");
$return_arr['success'] = "False";
$return_arr['message'] = "Can only send GET requests to this endpoint.";
echo json_encode($return_arr);
exit();
}
// Specific certificate via ID (single) // Specific certificate via ID (single)
if(isset($_GET['certificate_id'])){ if(isset($_GET['certificate_id'])){

View File

@@ -1,13 +1,7 @@
<?php <?php
require('../validate_api_key.php'); require('../validate_api_key.php');
if($_SERVER['REQUEST_METHOD'] !== "GET"){ require('../require_get_method.php');
header("HTTP/1.1 405 Method Not Allowed");
$return_arr['success'] = "False";
$return_arr['message'] = "Can only send GET requests to this endpoint.";
echo json_encode($return_arr);
exit();
}
// Specific contact via ID (single) // Specific contact via ID (single)
if(isset($_GET['contact_id'])){ if(isset($_GET['contact_id'])){

View File

@@ -1,13 +1,7 @@
<?php <?php
require('../validate_api_key.php'); require('../validate_api_key.php');
if($_SERVER['REQUEST_METHOD'] !== "GET"){ require('../require_get_method.php');
header("HTTP/1.1 405 Method Not Allowed");
$return_arr['success'] = "False";
$return_arr['message'] = "Can only send GET requests to this endpoint.";
echo json_encode($return_arr);
exit();
}
// Specific domain via ID (single) // Specific domain via ID (single)
if(isset($_GET['domain_id'])){ if(isset($_GET['domain_id'])){

View File

@@ -1,13 +1,7 @@
<?php <?php
require('../validate_api_key.php'); require('../validate_api_key.php');
if($_SERVER['REQUEST_METHOD'] !== "GET"){ require('../require_get_method.php');
header("HTTP/1.1 405 Method Not Allowed");
$return_arr['success'] = "False";
$return_arr['message'] = "Can only send GET requests to this endpoint.";
echo json_encode($return_arr);
exit();
}
// Specific network via ID (single) // Specific network via ID (single)
if(isset($_GET['network_id'])){ if(isset($_GET['network_id'])){

View File

@@ -0,0 +1,8 @@
<?php
if($_SERVER['REQUEST_METHOD'] !== "GET"){
header("HTTP/1.1 405 Method Not Allowed");
$return_arr['success'] = "False";
$return_arr['message'] = "Can only send GET requests to this endpoint.";
echo json_encode($return_arr);
exit();
}

View File

@@ -1,13 +1,7 @@
<?php <?php
require('../validate_api_key.php'); require('../validate_api_key.php');
if($_SERVER['REQUEST_METHOD'] !== "GET"){ require('../require_get_method.php');
header("HTTP/1.1 405 Method Not Allowed");
$return_arr['success'] = "False";
$return_arr['message'] = "Can only send GET requests to this endpoint.";
echo json_encode($return_arr);
exit();
}
// Specific software via ID (single) // Specific software via ID (single)
if(isset($_GET['software_id'])){ if(isset($_GET['software_id'])){

View File

@@ -1,13 +1,7 @@
<?php <?php
require('../validate_api_key.php'); require('../validate_api_key.php');
if($_SERVER['REQUEST_METHOD'] !== "GET"){ require('../require_get_method.php');
header("HTTP/1.1 405 Method Not Allowed");
$return_arr['success'] = "False";
$return_arr['message'] = "Can only send GET requests to this endpoint.";
echo json_encode($return_arr);
exit();
}
// Specific ticket via ID (single) // Specific ticket via ID (single)
if(isset($_GET['ticket_id'])){ if(isset($_GET['ticket_id'])){