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
require('../validate_api_key.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();
}
require('../require_get_method.php');
// Asset via ID (single)
if(isset($_GET['asset_id'])){

View File

@ -1,13 +1,7 @@
<?php
require('../validate_api_key.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();
}
require('../require_get_method.php');
// Specific certificate via ID (single)
if(isset($_GET['certificate_id'])){

View File

@ -1,13 +1,7 @@
<?php
require('../validate_api_key.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();
}
require('../require_get_method.php');
// Specific contact via ID (single)
if(isset($_GET['contact_id'])){

View File

@ -1,13 +1,7 @@
<?php
require('../validate_api_key.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();
}
require('../require_get_method.php');
// Specific domain via ID (single)
if(isset($_GET['domain_id'])){

View File

@ -1,13 +1,7 @@
<?php
require('../validate_api_key.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();
}
require('../require_get_method.php');
// Specific network via ID (single)
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
require('../validate_api_key.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();
}
require('../require_get_method.php');
// Specific software via ID (single)
if(isset($_GET['software_id'])){

View File

@ -1,13 +1,7 @@
<?php
require('../validate_api_key.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();
}
require('../require_get_method.php');
// Specific ticket via ID (single)
if(isset($_GET['ticket_id'])){