Add response for JSON only

This commit is contained in:
Philipp 2021-12-06 00:06:56 +01:00
parent d925e25424
commit fb1e8e75f5
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
3 changed files with 13 additions and 3 deletions

View file

@ -221,6 +221,16 @@ class ApiResponse extends Response
$this->addContent($return);
}
/**
* Wrapper around exit() for JSON only responses
*
* @param array $data
*/
public function exitWithJson(array $data)
{
$this->exit('content', ['content' => $data], static::TYPE_JSON);
}
/**
* Quit execution with the message that the endpoint isn't implemented
*

View file

@ -52,6 +52,6 @@ class VerifyCredentials extends BaseApi
// @todo Support the source property,
$account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid);
$this->response->exit('account', ['account' => $account->toArray()]);
$this->response->exitWithJson($account->toArray());
}
}