Skip to content

Commit a58301d

Browse files
committed
Default Favicon Endpoint
1 parent 210b064 commit a58301d

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types=1);
2+
3+
/*
4+
* This file is a part of the Civ14 project.
5+
*
6+
* Copyright (c) 2025-present Valithor Obsidion <[email protected]>
7+
*/
8+
9+
namespace VerifierServer\Endpoints;
10+
11+
use React\Http\Message\Response;
12+
use VerifierServer\Endpoint;
13+
14+
class FaviconEndpoint extends Endpoint
15+
{
16+
public function handle(
17+
string $method,
18+
$request,
19+
int|string &$response,
20+
array &$headers,
21+
string &$body
22+
): void {
23+
$response = Response::STATUS_OK;
24+
$headers = ['Content-Type' => 'image/x-icon'];
25+
$body = is_file($faviconPath = __DIR__ . '/../../assets/favicon.ico')
26+
? file_get_contents($faviconPath)
27+
: '';
28+
}
29+
}

src/VerifierServer/Server.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
use React\Http\Message\ServerRequest;
1818
use SS14\Endpoints\OAuth2Endpoint as SS14OAuth2Endpoint;
1919
use VerifierServer\Endpoints\Interfaces\EndpointInterface;
20-
//use VerifierServer\Endpoints\USPSEndpoint;
20+
use VerifierServer\Endpoints\FaviconEndpoint;
2121
use VerifierServer\Endpoints\SS14VerifiedEndpoint;
22+
//use VerifierServer\Endpoints\USPSEndpoint;
2223
use VerifierServer\Endpoints\VerifiedEndpoint;
2324
use VerifierServer\Traits\HttpMethodsTrait;
2425

@@ -128,6 +129,7 @@ public function __construct(
128129
}
129130
protected function afterConstruct(): void
130131
{
132+
$this->endpoints['/favicon.ico'] = new FaviconEndpoint(new FaviconEndpoint());
131133
//$this->endpoints['/usps'] = new USPSEndpoint($_ENV['USPS_USERID'] ?? getenv('USPS_USERID'));
132134
}
133135

0 commit comments

Comments
 (0)