|
9 | 9 | |
|
10 | 10 | */
|
11 | 11 |
|
12 |
| -Route::group(['prefix' => config('shopify-app.prefix'), 'middleware' => ['web']], function () { |
| 12 | +use Illuminate\Support\Facades\Config; |
| 13 | +use Illuminate\Support\Facades\Route; |
| 14 | +use function Osiset\ShopifyApp\registerPackageRoute; |
| 15 | + |
| 16 | +// Check if manual routes override is to be use |
| 17 | +$manualRoutes = Config::get('shopify-app.manual_routes'); |
| 18 | +if ($manualRoutes) { |
| 19 | + // Get a list of route names to exclude |
| 20 | + $manualRoutes = explode(',', $manualRoutes); |
| 21 | +} |
| 22 | + |
| 23 | +Route::group(['prefix' => config('shopify-app.prefix'), 'middleware' => ['web']], function () use ($manualRoutes) { |
13 | 24 | /*
|
14 | 25 | |--------------------------------------------------------------------------
|
15 | 26 | | Home Route
|
|
20 | 31 | |
|
21 | 32 | */
|
22 | 33 |
|
23 |
| - Route::get( |
24 |
| - '/', |
25 |
| - 'Osiset\ShopifyApp\Http\Controllers\HomeController@index' |
26 |
| - ) |
27 |
| - ->middleware(['auth.shopify', 'billable']) |
28 |
| - ->name('home'); |
| 34 | + if (registerPackageRoute('home', $manualRoutes)) { |
| 35 | + Route::get( |
| 36 | + '/', |
| 37 | + 'Osiset\ShopifyApp\Http\Controllers\HomeController@index' |
| 38 | + ) |
| 39 | + ->middleware(['auth.shopify', 'billable']) |
| 40 | + ->name('home'); |
| 41 | + } |
29 | 42 |
|
30 | 43 | /*
|
31 | 44 | |--------------------------------------------------------------------------
|
|
36 | 49 | |
|
37 | 50 | */
|
38 | 51 |
|
39 |
| - Route::match( |
40 |
| - ['get', 'post'], |
41 |
| - '/authenticate', |
42 |
| - 'Osiset\ShopifyApp\Http\Controllers\AuthController@authenticate' |
43 |
| - ) |
44 |
| - ->name('authenticate'); |
| 52 | + if (registerPackageRoute('authenticate', $manualRoutes)) { |
| 53 | + Route::match( |
| 54 | + ['get', 'post'], |
| 55 | + '/authenticate', |
| 56 | + 'Osiset\ShopifyApp\Http\Controllers\AuthController@authenticate' |
| 57 | + ) |
| 58 | + ->name('authenticate'); |
| 59 | + } |
45 | 60 |
|
46 | 61 | /*
|
47 | 62 | |--------------------------------------------------------------------------
|
|
52 | 67 | |
|
53 | 68 | */
|
54 | 69 |
|
55 |
| - Route::get( |
56 |
| - '/authenticate/oauth', |
57 |
| - 'Osiset\ShopifyApp\Http\Controllers\AuthController@oauth' |
58 |
| - ) |
59 |
| - ->name('authenticate.oauth'); |
| 70 | + if (registerPackageRoute('authenticate.oauth', $manualRoutes)) { |
| 71 | + Route::get( |
| 72 | + '/authenticate/oauth', |
| 73 | + 'Osiset\ShopifyApp\Http\Controllers\AuthController@oauth' |
| 74 | + ) |
| 75 | + ->name('authenticate.oauth'); |
| 76 | + } |
60 | 77 |
|
61 | 78 | /*
|
62 | 79 | |--------------------------------------------------------------------------
|
|
67 | 84 | |
|
68 | 85 | */
|
69 | 86 |
|
70 |
| - Route::get( |
71 |
| - '/billing/{plan?}', |
72 |
| - 'Osiset\ShopifyApp\Http\Controllers\BillingController@index' |
73 |
| - ) |
74 |
| - ->middleware(['auth.shopify']) |
75 |
| - ->where('plan', '^([0-9]+|)$') |
76 |
| - ->name('billing'); |
| 87 | + if (registerPackageRoute('billing', $manualRoutes)) { |
| 88 | + Route::get( |
| 89 | + '/billing/{plan?}', |
| 90 | + 'Osiset\ShopifyApp\Http\Controllers\BillingController@index' |
| 91 | + ) |
| 92 | + ->middleware(['auth.shopify']) |
| 93 | + ->where('plan', '^([0-9]+|)$') |
| 94 | + ->name('billing'); |
| 95 | + } |
77 | 96 |
|
78 | 97 | /*
|
79 | 98 | |--------------------------------------------------------------------------
|
|
84 | 103 | |
|
85 | 104 | */
|
86 | 105 |
|
87 |
| - Route::get( |
88 |
| - '/billing/process/{plan?}', |
89 |
| - 'Osiset\ShopifyApp\Http\Controllers\BillingController@process' |
90 |
| - ) |
91 |
| - ->middleware(['auth.shopify']) |
92 |
| - ->where('plan', '^([0-9]+|)$') |
93 |
| - ->name('billing.process'); |
| 106 | + if (registerPackageRoute('billing.process', $manualRoutes)) { |
| 107 | + Route::get( |
| 108 | + '/billing/process/{plan?}', |
| 109 | + 'Osiset\ShopifyApp\Http\Controllers\BillingController@process' |
| 110 | + ) |
| 111 | + ->middleware(['auth.shopify']) |
| 112 | + ->where('plan', '^([0-9]+|)$') |
| 113 | + ->name('billing.process'); |
| 114 | + } |
94 | 115 |
|
95 | 116 | /*
|
96 | 117 | |--------------------------------------------------------------------------
|
|
101 | 122 | |
|
102 | 123 | */
|
103 | 124 |
|
104 |
| - Route::match( |
105 |
| - ['get', 'post'], |
106 |
| - '/billing/usage-charge', |
107 |
| - 'Osiset\ShopifyApp\Http\Controllers\BillingController@usageCharge' |
108 |
| - ) |
109 |
| - ->middleware(['auth.shopify']) |
110 |
| - ->name('billing.usage_charge'); |
| 125 | + if (registerPackageRoute('billing.usage_charge', $manualRoutes)) { |
| 126 | + Route::match( |
| 127 | + ['get', 'post'], |
| 128 | + '/billing/usage-charge', |
| 129 | + 'Osiset\ShopifyApp\Http\Controllers\BillingController@usageCharge' |
| 130 | + ) |
| 131 | + ->middleware(['auth.shopify']) |
| 132 | + ->name('billing.usage_charge'); |
| 133 | + } |
111 | 134 | });
|
112 | 135 |
|
113 |
| -Route::group(['middleware' => ['api']], function () { |
| 136 | +Route::group(['middleware' => ['api']], function () use ($manualRoutes) { |
114 | 137 | /*
|
115 | 138 | |--------------------------------------------------------------------------
|
116 | 139 | | Webhook Handler
|
|
120 | 143 | |
|
121 | 144 | */
|
122 | 145 |
|
123 |
| - Route::post( |
124 |
| - '/webhook/{type}', |
125 |
| - 'Osiset\ShopifyApp\Http\Controllers\WebhookController@handle' |
126 |
| - ) |
127 |
| - ->middleware('auth.webhook') |
128 |
| - ->name('webhook'); |
| 146 | + if (registerPackageRoute('webhook', $manualRoutes)) { |
| 147 | + Route::post( |
| 148 | + '/webhook/{type}', |
| 149 | + 'Osiset\ShopifyApp\Http\Controllers\WebhookController@handle' |
| 150 | + ) |
| 151 | + ->middleware('auth.webhook') |
| 152 | + ->name('webhook'); |
| 153 | + } |
129 | 154 | });
|
0 commit comments