AspireCloud/routes/inc/download.php
Chuck Adams 1fa094eb0f
Determine asset content-type from extension (#163)
* tweak: disable deprecations dammit

* fix: add Asset::getContentType() so as to stop using octet-stream

* feat: add handy bin/dbsh script alternative to 'php artisan db'

* fix: loosen up slug pattern
2025-02-12 15:26:12 -07:00

49 lines
1.9 KiB
PHP

<?php
use App\Http\Controllers\API\WpOrg\Downloads\DownloadCoreController;
use App\Http\Controllers\API\WpOrg\Downloads\DownloadPluginAssetController;
use App\Http\Controllers\API\WpOrg\Downloads\DownloadPluginController;
use App\Http\Controllers\API\WpOrg\Downloads\DownloadPluginIconController;
use App\Http\Controllers\API\WpOrg\Downloads\DownloadThemeController;
use App\Http\Controllers\API\WpOrg\Downloads\DownloadThemeScreenshotController;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
$cache_seconds = config('app.aspirecloud.download.cache_seconds');
$middleware = [
"cache.headers:public;max_age=$cache_seconds", // we're streaming responses, so no etags
];
Route::prefix('/')
->middleware($middleware)
->group(function (Router $router) {
$router
->get('/download/wordpress-{version}.{extension}', DownloadCoreController::class)
->where(['version' => '[\d.]+', 'extension' => 'zip|tar\.gz'])
->name('download.core');
$router
->get('/download/plugin/{file}', DownloadPluginController::class)
->where(['file' => '.+\.zip'])
->name('download.plugin');
$router
->get('/download/theme/{file}', DownloadThemeController::class)
->where(['file' => '.+\.zip'])
->name('download.theme');
$router
->get('/download/assets/plugin/{slug}/{revision}/{file}', DownloadPluginAssetController::class)
->where(['file' => '.+'])
->name('download.plugin.asset');
$router
->get('/download/gp-icon/plugin/{slug}/{revision}/{file}', DownloadPluginIconController::class)
->where(['file' => '.+'])
->name('download.plugin.gp-icon');
$router
->get('/download/assets/theme/{slug}/{revision}/{file}', DownloadThemeScreenshotController::class)
->where(['file' => '.+'])
->name('download.theme.asset');
});