Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

### Changed

- Requires `innmind/operating-system:~6.0`
- Requires `innmind/http:~8.0`

### Fixed

- PHP `8.4` deprecation
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
},
"require": {
"php": "~8.2",
"innmind/http": "~7.0",
"innmind/operating-system": "~4.0|~5.0"
"innmind/http": "~8.0",
"innmind/operating-system": "~6.0"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 6 additions & 5 deletions fixtures/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
require __DIR__.'/../vendor/autoload.php';

use Innmind\HttpServer\Main;
use Innmind\Http\Message\{
use Innmind\Http\{
ServerRequest,
Response,
StatusCode,
Response\StatusCode,
};
use Innmind\Filesystem\File\Content;

new class extends Main
{
protected function main(ServerRequest $request): Response
{
//echo back server
return new Response\Response(
// Echo back server
return Response::of(
StatusCode::ok,
$request->protocolVersion(),
null,
$request->body(),
Content::ofString('Hello world'),
);
}
};
12 changes: 7 additions & 5 deletions src/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
namespace Innmind\HttpServer;

use Innmind\Http\{
Factory\ServerRequest\ServerRequestFactory,
ResponseSender,
Factory\ServerRequestFactory,
Response\Sender\Native,
ServerRequest,
ServerRequest\Environment,
Response,
Expand All @@ -25,8 +25,8 @@ abstract class Main
final public function __construct(?Config $config = null)
{
$os = Factory::build($config);
$makeRequest = ServerRequestFactory::default($os->clock());
$send = new ResponseSender($os->clock());
$makeRequest = ServerRequestFactory::native($os->clock());
$send = Native::of($os->clock());

try {
$request = $makeRequest();
Expand All @@ -41,10 +41,12 @@ final public function __construct(?Config $config = null)
try {
$response = $this->main($request);
} catch (\Throwable $e) {
throw $e;
$response = $this->serverError($request);
}

$send($response);
// Swallow errors to never render them to the client
$_ = $send($response)->memoize();

$this->terminate($request, $response);
}
Expand Down