| @@ -6,8 +6,9 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace WCPOS\WooCommercePOS\API\V2; |
| 9 | 9 | |
| 10 | +use WCPOS\WooCommercePOS\API\V2\Proxy\Fast_Path_Behavior; | |
| 10 | 11 | use WCPOS\WooCommercePOS\API\V2\Proxy\Null_Proxy_Behavior; |
| 11 | 12 | use WCPOS\WooCommercePOS\API\V2\Proxy\Proxy_Behavior; |
| 12 | 13 | use WCPOS\WooCommercePOS\Sync\Api; |
| 13 | 14 | use WCPOS\WooCommercePOS\Sync\Collections; |
| @@ -72,8 +73,14 @@ | ||
| 72 | 73 | * client sees the same failure it would have seen hitting wc/v3 directly. |
| 73 | 74 | */ |
| 74 | 75 | public function proxy( WP_REST_Request $request, string $wc_route, string $resource, ?Proxy_Behavior $behavior = null ) { |
| 75 | 76 | $behavior = $behavior ?? self::behavior_for( $resource ); |
| 77 | + if ( $behavior instanceof Fast_Path_Behavior ) { | |
| 78 | + $fast = $behavior->fast_response( $request ); | |
| 79 | + if ( null !== $fast ) { | |
| 80 | + return $fast; | |
| 81 | + } | |
| 82 | + } | |
| 76 | 83 | $query_params = $behavior->forwarded_params( $request->get_query_params(), $request ); |
| 77 | 84 | $inner = new WP_REST_Request( WP_REST_Server::READABLE, $wc_route ); |
| 78 | 85 | unset( $query_params[ Store_Scope::PARAM ] ); |
| 79 | 86 | $inner->set_query_params( $query_params ); |