[wp-trac] [WordPress Trac] #35822: Add support for PATCH method to REST API infrastructure

WordPress Trac noreply at wordpress.org
Wed Mar 2 01:45:33 UTC 2016


#35822: Add support for PATCH method to REST API infrastructure
--------------------------+------------------------------
 Reporter:  westonruter   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  REST API      |     Version:  4.4
 Severity:  normal        |  Resolution:
 Keywords:  close         |     Focuses:
--------------------------+------------------------------
Changes (by rmccue):

 * keywords:   => close


Comment:

 IMO, we should close this as maybelater. The API can already handle PATCH
 requests, you just need to handle the patch format yourself in the
 endpoints. I think we should work out how we want JSON Patch operations to
 work first before we roll it into the infrastructure; the customiser
 provides a good place to do that and experiment.

 Right now, something like this should already work:
 {{{
 register_rest_route( 'customizer/v1', '/test', array(
         'methods' => 'PATCH',
         'callback' => function ( WP_REST_Request $request ) {
                 $body = $request->get_body();

                 // Parse JSON Patch format into instructions
                 $data = Some_JSON_Patch_Parser::parse( $body );

                 // Do something with the instructions
         }
 );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35822#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list