-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroutes.php
35 lines (28 loc) · 1.33 KB
/
routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Response;
use Webmaxx\Seo\Classes\Generators\AdsTxtGenerator;
use Webmaxx\Seo\Classes\Generators\AppAdsTxtGenerator;
use Webmaxx\Seo\Classes\Generators\HumansTxtGenerator;
use Webmaxx\Seo\Classes\Generators\RobotsTxtGenerator;
use Webmaxx\Seo\Classes\Generators\SecurityTxtGenerator;
use Webmaxx\Seo\Models\Settings;
Event::listen('system.beforeRoute', function () {
$txtResponse = fn($generatorClass) => Response::make(app($generatorClass)->render())->header('Content-Type', 'text/plain');
if (Settings::get('robots_txt_enabled')) {
Route::get('robots.txt', fn() => $txtResponse(RobotsTxtGenerator::class));
}
if (Settings::get('humans_txt_enabled')) {
Route::get('humans.txt', fn() => $txtResponse(HumansTxtGenerator::class));
}
if (Settings::get('security_txt_enabled')) {
Route::get('security.txt', fn() => $txtResponse(SecurityTxtGenerator::class));
Route::get('.well-known/security.txt', fn() => $txtResponse(SecurityTxtGenerator::class));
}
if (Settings::get('ads_txt_enabled')) {
Route::get('ads.txt', fn() => $txtResponse(AdsTxtGenerator::class));
}
if (Settings::get('app_ads_txt_enabled')) {
Route::get('app-ads.txt', fn() => $txtResponse(AppAdsTxtGenerator::class));
}
});