refactor: add content type to all outgoing addTask responses
This commit is contained in:
parent
f4894f40ce
commit
0e44c78af6
@ -38,7 +38,7 @@ class TaskController
|
||||
$this->builder->setErrorMessage('Malformed request payload. Please try again.');
|
||||
$this->builder->setErrorCode(400);
|
||||
|
||||
$errorResponse = $response->withStatus(400, 'Invalid payload');
|
||||
$errorResponse = $response->withStatus(400, 'Invalid payload')->withHeader('Content-Type', 'application/json');
|
||||
$errorResponse->getBody()->write($this->builder->build());
|
||||
|
||||
return $errorResponse;
|
||||
@ -57,7 +57,7 @@ class TaskController
|
||||
$this->builder->setErrorMessage("The following parameters are missing: " . implode(', ', $missingKeys));
|
||||
$this->builder->setErrorCode(400);
|
||||
|
||||
$errorResponse = $response->withStatus('400', 'Missing arguments');
|
||||
$errorResponse = $response->withStatus('400', 'Missing arguments')->withHeader('Content-Type', 'application/json');
|
||||
$errorResponse->getBody()->write($this->builder->build());
|
||||
|
||||
return $errorResponse;
|
||||
@ -78,7 +78,7 @@ class TaskController
|
||||
$this->builder->setErrorMessage($exception->getMessage());
|
||||
$this->builder->setErrorCode(400);
|
||||
|
||||
$errorResponse = $response->withStatus(400);
|
||||
$errorResponse = $response->withStatus(400)->withHeader('Content-Type', 'application/json');
|
||||
$errorResponse->getBody()->write($this->builder->build());
|
||||
|
||||
return $errorResponse;
|
||||
@ -89,7 +89,7 @@ class TaskController
|
||||
$this->builder->setErrorCode(400);
|
||||
$this->builder->setErrorMessage('Invalid task status code. Status must range from 1-4 (started, in progress, blocked, completed).');
|
||||
|
||||
$errorResponse = $response->withStatus(400);
|
||||
$errorResponse = $response->withStatus(400)->withHeader('Content-Type', 'application/json');
|
||||
$errorResponse->getBody()->write($this->builder->build());
|
||||
|
||||
return $errorResponse;
|
||||
@ -108,13 +108,13 @@ class TaskController
|
||||
->setErrorMessage('An unexpected error has occurred whilst trying to perform this operation.')
|
||||
->setErrorCode(500);
|
||||
|
||||
$errorResponse = $response->withStatus(500);
|
||||
$errorResponse = $response->withStatus(500)->withHeader('Content-Type', 'application/json');
|
||||
$errorResponse->getBody()->write($this->builder->build());
|
||||
|
||||
return $errorResponse;
|
||||
}
|
||||
|
||||
$createdResponse = $response->withStatus(201);
|
||||
$createdResponse = $response->withStatus(201)->withHeader('Content-Type', 'application/json');
|
||||
$this->builder->setOptionalMessage('Task created.')
|
||||
->setPayload($task->persist());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user