31 lines
No EOL
965 B
PHP
31 lines
No EOL
965 B
PHP
<?php
|
|
require_once 'config.php';
|
|
require_once 'AuthMiddleware.php';
|
|
|
|
// Require authentication for this endpoint
|
|
$auth = new AuthMiddleware();
|
|
$user = $auth->requireAuth();
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
$markdown = $input['markdown'] ?? $_POST['markdown'] ?? '';
|
|
|
|
if (empty($markdown)) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => 'No markdown content provided']);
|
|
exit;
|
|
}
|
|
|
|
// You can add additional processing or sanitization here if needed
|
|
// For now, we're just passing through the markdown (conversion happens client-side)
|
|
|
|
echo json_encode([
|
|
'html' => $markdown,
|
|
'processed_by' => $user['name'] ?? $user['preferred_username'] ?? 'Unknown User'
|
|
]);
|
|
} else {
|
|
http_response_code(405);
|
|
echo json_encode(['error' => 'Method not allowed']);
|
|
} |