Add www/api/public/index.php
This commit is contained in:
20
www/api/public/index.php
Normal file
20
www/api/public/index.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* api.domain.de — REST API
|
||||||
|
*/
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$method = $_SERVER['REQUEST_METHOD'];
|
||||||
|
|
||||||
|
switch ($method) {
|
||||||
|
case 'GET':
|
||||||
|
echo json_encode(['status' => 'ok', 'message' => 'API läuft']);
|
||||||
|
break;
|
||||||
|
case 'POST':
|
||||||
|
$input = json_decode(file_get_contents('php://input'), true);
|
||||||
|
echo json_encode(['status' => 'received', 'data' => $input]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
http_response_code(405);
|
||||||
|
echo json_encode(['error' => 'Method not allowed']);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user