Automattic\WooCommerce\StoreApi\Routes\V1

AbstractRoute::get_response_by_request_method()protectedWC 1.0

Get the route response based on the type of request.

Method of the class: AbstractRoute{}

No Hooks.

Return

\WP_REST_Response.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_response_by_request_method( $request );
$request(\WP_REST_Request) (required)
Request object.

AbstractRoute::get_response_by_request_method() code WC 9.3.3

protected function get_response_by_request_method( \WP_REST_Request $request ) {
	switch ( $request->get_method() ) {
		case 'POST':
			return $this->get_route_post_response( $request );
		case 'PUT':
		case 'PATCH':
			return $this->get_route_update_response( $request );
		case 'DELETE':
			return $this->get_route_delete_response( $request );
	}
	return $this->get_route_response( $request );
}