2025-07-17 10:05:47 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Route;
|
2026-03-13 02:06:44 +09:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2025-07-17 10:05:47 +09:00
|
|
|
|
|
|
|
|
Route::get('/', function () {
|
2025-08-08 17:13:31 +09:00
|
|
|
return redirect('/api-docs/index.html');
|
2025-07-17 10:05:47 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Sanctum 인증을 사용하는 웹 라우트
|
2025-11-06 17:45:49 +09:00
|
|
|
Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified'])->group(function () {
|
2025-07-17 10:05:47 +09:00
|
|
|
|
|
|
|
|
Route::get('/dashboard', function () {
|
|
|
|
|
return view('dashboard');
|
|
|
|
|
})->name('dashboard');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-13 02:06:44 +09:00
|
|
|
// R2 정적 이미지 프록시 (인증 불필요, 캐시 1일)
|
|
|
|
|
Route::get('/images/{path}', function (string $path) {
|
|
|
|
|
$r2Path = 'images/'.$path;
|
|
|
|
|
|
|
|
|
|
if (! Storage::disk('r2')->exists($r2Path)) {
|
|
|
|
|
abort(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mime = Storage::disk('r2')->mimeType($r2Path);
|
|
|
|
|
$stream = Storage::disk('r2')->readStream($r2Path);
|
|
|
|
|
|
|
|
|
|
return response()->stream(function () use ($stream) {
|
|
|
|
|
fpassthru($stream);
|
|
|
|
|
if (is_resource($stream)) {
|
|
|
|
|
fclose($stream);
|
|
|
|
|
}
|
|
|
|
|
}, 200, [
|
|
|
|
|
'Content-Type' => $mime,
|
|
|
|
|
'Cache-Control' => 'public, max-age=86400',
|
|
|
|
|
]);
|
|
|
|
|
})->where('path', '.*');
|
|
|
|
|
|
2026-03-13 10:13:50 +09:00
|
|
|
// R2 테넌트 파일 프록시 (문서 템플릿 이미지 등, 인증 불필요, 캐시 1일)
|
|
|
|
|
Route::get('/storage/tenants/{path}', function (string $path) {
|
|
|
|
|
if (! Storage::disk('r2')->exists($path)) {
|
|
|
|
|
abort(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mime = Storage::disk('r2')->mimeType($path);
|
|
|
|
|
$stream = Storage::disk('r2')->readStream($path);
|
|
|
|
|
|
|
|
|
|
return response()->stream(function () use ($stream) {
|
|
|
|
|
fpassthru($stream);
|
|
|
|
|
if (is_resource($stream)) {
|
|
|
|
|
fclose($stream);
|
|
|
|
|
}
|
|
|
|
|
}, 200, [
|
|
|
|
|
'Content-Type' => $mime,
|
|
|
|
|
'Cache-Control' => 'public, max-age=86400',
|
|
|
|
|
]);
|
|
|
|
|
})->where('path', '.*');
|
|
|
|
|
|
2025-11-06 17:45:49 +09:00
|
|
|
// Swagger 설정
|
2025-07-17 10:05:47 +09:00
|
|
|
Route::get('/docs/api-docs.json', function () {
|
|
|
|
|
return response()->file(storage_path('api-docs/api-docs.json'));
|
|
|
|
|
});
|
|
|
|
|
Route::middleware('swagger.auth')->group(function () {
|
|
|
|
|
Route::get('/api/documentation', function () {
|
|
|
|
|
return response()->file(public_path('swagger-ui/index.html'));
|
|
|
|
|
});
|
|
|
|
|
});
|