WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Routes

AbstractRoute::get_response() public WC 1.0

Get the route response based on the type of request.

{} It's a method of the class: AbstractRoute{}

No Hooks.

Return

\WP_REST_Response.

Usage

$AbstractRoute = new AbstractRoute();
$AbstractRoute->get_response( $request );
$request(WP_REST_Request) (required)
Request object.

Code of AbstractRoute::get_response() WC 5.7.1

public function get_response( \WP_REST_Request $request ) {
	$response = null;
	try {
		switch ( $request->get_method() ) {
			case 'POST':
				$response = $this->get_route_post_response( $request );
				break;
			case 'PUT':
			case 'PATCH':
				$response = $this->get_route_update_response( $request );
				break;
			case 'DELETE':
				$response = $this->get_route_delete_response( $request );
				break;
			default:
				$response = $this->get_route_response( $request );
				break;
		}
	} catch ( RouteException $error ) {
		$response = $this->get_route_error_response( $error->getErrorCode(), $error->getMessage(), $error->getCode(), $error->getAdditionalData() );
	} catch ( InvalidStockLevelsInCartException $error ) {
		$response = $this->get_route_error_response_from_object( $error->getError(), $error->getCode(), $error->getAdditionalData() );
	} catch ( \Exception $error ) {
		$response = $this->get_route_error_response( 'unknown_server_error', $error->getMessage(), 500 );
	}

	if ( is_wp_error( $response ) ) {
		$response = $this->error_to_response( $response );
	}

	return $response;
}