<?php
defined('ABSPATH') or die();
add_action( 'rest_api_init', function () {
    register_rest_route( 'darkey/v1', '/set_post_rating', array(
        'methods' => 'POST',
        'callback' => 'drk_post_voting',
        'permission_callback' => '__return_true',
        'args' => [
            'vote' => [
                'required' => true,
                'type' => 'string',
            ],
            'post_id' => [
                'required' => true,
                'type' => 'integer',
            ],
        ]
    ));
});