empress-php / empress

Empress is a flexible microframework for creating async web applications in PHP 8.1.
MIT License
15 stars 0 forks source link

Error handlers should allow for header filtering #41

Closed jakobmats closed 2 years ago

jakobmats commented 3 years ago

Status handlers allow for specifying request headers while error handlers do not:

$app->status(Status::NOT_FOUND, function (Context $ctx) {
    $ctx->html('<h1>Not found</h1>');
}, ['Accept' => 'text/html']);

$app->status(Status::NOT_FOUND, function (Context $ctx) {
    $ctx->json(['status' => 'Not found']);
}, ['Accept' => 'application/json']);

This should be unified.

jakobmats commented 3 years ago

In the simplified design both types of mappers will only support content type filtering as it seems to be the only useful case for request headers.