<?php

defined('ABSPATH') or die();

function drk_validate(WP_REST_Request $request)
{
    global $error;
    $header = $request->get_headers();
    $token = $header['authorization'][0];
    $token = str_replace("Bearer ","", $token);
    return drk_validate_token($token);
}

function drk_validate_rest()
{
register_rest_route('auth/v1', '/validate', [
    'methods' => 'POST',
    'callback' => 'drk_validate',
    'permission_callback' => '__return_true'
]);
}
add_action('rest_api_init', 'drk_validate_rest');