Skip to content

Instantly share code, notes, and snippets.

@mattheu
Last active October 24, 2016 16:18
Show Gist options
  • Save mattheu/60e63342bb203760e23752e9383c977f to your computer and use it in GitHub Desktop.
Save mattheu/60e63342bb203760e23752e9383c977f to your computer and use it in GitHub Desktop.
<?php
add_action( 'rest_api_init', 'wpleeds_rest_api' );
function wpleeds_rest_api() {
register_rest_route(
'wpleeds/v1',
'/movies/(?P<name>.+)/?$',
[
'methods' => WP_Rest_Server::READABLE,
'callback' => 'get_movie',
]
);
}
function get_movie( WP_REST_Request $request ) {
return [
'name' => 'Mad Max: Fury Road',
'director' => 'George Miller',
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment