Apigility と呼ばれる ZF2 (Zend Framework 2) に基づくフレームワークで API を作成しました。
私のサービスは、サードパーティの API を照会できます。トークンの有効期限が切れているなどの理由で、500 エラー メッセージが返されることがあります。
MY API はクライアントにどのように応答する必要がありますか?
最初は 500 を返すべきだと思ったのですが、実際にはそうではないようです。クラッシュしたことを示すエラーを返したくありません.. 500 を取得したのはサード パーティです。
更新:以下は、サードパーティから見たものです。
私は .. のアイデアが好きだと思い503 Service unavailable
ます..エラーメッセージがユーザーに何が問題なのか、そしてそれを修正する方法を教えてくれます。
サードパーティの応答を示す更新:
Error performing request to OAuth Provider.
HTTP/1.1 500 Internal Server Error
Server: nginx/1.1.19
Date: Fri, 22 Aug 2014 20:24:40 GMT
Content-Type: text/html
Content-Length: 20
Connection: close
X-Powered-By: PHP/5.3.10-1ubuntu3.1
Set-Cookie: lang_select_language=en; Expires=Sun, 21-Aug-2016 20:24:42 GMT; Path=/
X-WI-SRV: FR-EQX-WEB-03
Vary: Accept-Encoding
Content-Encoding: gzip
考え?
/**
* Status titles for common problems
*
* @var array
*/
protected $problemStatusTitles = array(
// CLIENT ERROR
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Time-out',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Large',
415 => 'Unsupported Media Type',
416 => 'Requested range not satisfiable',
417 => 'Expectation Failed',
418 => 'I\'m a teapot',
422 => 'Unprocessable Entity',
423 => 'Locked',
424 => 'Failed Dependency',
425 => 'Unordered Collection',
426 => 'Upgrade Required',
428 => 'Precondition Required',
429 => 'Too Many Requests',
431 => 'Request Header Fields Too Large',
// SERVER ERROR
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Time-out',
505 => 'HTTP Version not supported',
506 => 'Variant Also Negotiates',
507 => 'Insufficient Storage',
508 => 'Loop Detected',
511 => 'Network Authentication Required',
);