Skip to content

Commit cb83984

Browse files
authored
Merge pull request #220 from dotkernel/issue-217
extend Link header
2 parents c901290 + 620931f commit cb83984

3 files changed

Lines changed: 79 additions & 22 deletions

File tree

‎config/autoload/headers.global.php‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$llmsTxtLink = '</llms.txt>; rel="llms-txt", </llms-full.txt>; rel="llms-full-txt"';
6+
$serviceDocLink = static fn (string $url): string => sprintf('<%s>; rel="service-doc", ', $url) . $llmsTxtLink;
7+
8+
return [
9+
'dot_response_headers' => [
10+
'*' => [
11+
'X-Powered-By' => [
12+
'value' => 'Dotkernel',
13+
'overwrite' => true,
14+
],
15+
'X-Llms-Txt' => [
16+
'value' => '/llms.txt',
17+
'overwrite' => true,
18+
],
19+
'Link' => [
20+
'value' => $llmsTxtLink,
21+
'overwrite' => true,
22+
],
23+
],
24+
'app::index' => [
25+
'Link' => [
26+
'value' => $serviceDocLink('https://docs.dotkernel.org/'),
27+
'overwrite' => true,
28+
],
29+
],
30+
'page::api' => [
31+
'Link' => [
32+
'value' => $serviceDocLink('https://docs.dotkernel.org/api-documentation/'),
33+
'overwrite' => true,
34+
],
35+
],
36+
'page::admin' => [
37+
'Link' => [
38+
'value' => $serviceDocLink('https://docs.dotkernel.org/admin-documentation/'),
39+
'overwrite' => true,
40+
],
41+
],
42+
'page::queue' => [
43+
'Link' => [
44+
'value' => $serviceDocLink('https://docs.dotkernel.org/queue-documentation/'),
45+
'overwrite' => true,
46+
],
47+
],
48+
'page::light' => [
49+
'Link' => [
50+
'value' => $serviceDocLink('https://docs.dotkernel.org/light-documentation/'),
51+
'overwrite' => true,
52+
],
53+
],
54+
'page::frontend' => [
55+
'Link' => [
56+
'value' => $serviceDocLink('https://docs.dotkernel.org/frontend/'),
57+
'overwrite' => true,
58+
],
59+
],
60+
'page::wsl2' => [
61+
'Link' => [
62+
'value' => $serviceDocLink('https://docs.dotkernel.org/development/v2/terminal/'),
63+
'overwrite' => true,
64+
],
65+
],
66+
'page::architecture' => [
67+
'Link' => [
68+
'value' => $serviceDocLink('https://docs.dotkernel.org/api-documentation/'),
69+
'overwrite' => true,
70+
],
71+
],
72+
],
73+
];

‎config/autoload/local.php.dist‎

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,19 @@ $app = [
4747
];
4848

4949
return [
50-
'application' => $app,
51-
'databases' => $databases,
52-
'dot_response_headers' => [
53-
'*' => [
54-
'X-Powered-By' => [
55-
'value' => $app['meta']['siteName'],
56-
'overwrite' => true,
57-
],
58-
'X-Llms-Txt' => [
59-
'value' => '/llms.txt',
60-
'overwrite' => true,
61-
],
62-
'Link' => [
63-
'value' => '</llms.txt>; rel="llms-txt", </llms-full.txt>; rel="llms-full-txt"',
64-
'overwrite' => true,
65-
],
66-
],
67-
],
68-
'doctrine' => [
50+
'application' => $app,
51+
'databases' => $databases,
52+
'doctrine' => [
6953
'connection' => [
7054
'orm_default' => [
7155
'params' => $databases['default'],
7256
],
7357
],
7458
],
75-
'feed' => [
59+
'feed' => [
7660
'path' => realpath(__DIR__ . '/../../public/feed.xml'),
7761
],
78-
'llms' => [
62+
'llms' => [
7963
'sourceDir' => realpath(__DIR__ . '/../../public/md-articles'),
8064
'outputFile' => realpath(__DIR__ . '/../../public/llms-full.txt'),
8165
// Markdown versions of the static pages, appended after the articles. Optional.

‎config/pipeline.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
// Register the routing middleware in the middleware pipeline.
4242
// This middleware registers the Mezzio\Router\RouteResult request attribute.
4343
$app->pipe(RouteMiddleware::class);
44-
$app->pipe(ResponseHeaderMiddleware::class);
4544

4645
// The following handle routing failures for common conditions:
4746
// - HEAD request but no routes answer that method
@@ -52,6 +51,7 @@
5251
$app->pipe(ImplicitHeadMiddleware::class);
5352
$app->pipe(ImplicitOptionsMiddleware::class);
5453
$app->pipe(MethodNotAllowedMiddleware::class);
54+
$app->pipe(ResponseHeaderMiddleware::class);
5555

5656
// Seed the UrlHelper with the routing results:
5757
$app->pipe(UrlHelperMiddleware::class);

0 commit comments

Comments
 (0)