美文网首页
数据库操作结果映射 http 状态码

数据库操作结果映射 http 状态码

作者: 萧哈哈 | 来源:发表于2018-08-25 08:42 被阅读27次

    出自

    DB Basic Operations

    Create

    • Successfully returns 201 + body { Record } + location header field + /{id} to locate it
    • Already Exits returns 409 + body { statusCode: 409 , message: ‘Resource with ID xx already exists, couldn't create’ }
    • General returns 500 + body { statusCode:500, message: ‘juggler original message’ }

    Read

    • Successfully returns 200 + body { Record }
    • Not found returns 404 + body { statusCode: 404 , message: ‘Resource with ID xx not found’ }
    • General returns 500 + body { statusCode:500, message: ‘juggler original message’ }

    Update

    • Successfully returns 200 + body { Record }
    • Not found returns 404 + body { statusCode: 404 , message: ‘Resource with ID xx not found, couldn't update' }
    • General returns 500 + body { statusCode:500, message: ‘juggler original message’ }

    Delete

    • Successfully returns 200 + body { Record }
    • Not found returns 404 + body { statusCode: 404 , message: ‘Resource with ID xx not found, couldn’t delete' }
    • General returns 500 + body { statusCode:500, message: ‘juggler original message’ }

    Notes
    1- { Record } is the full record, and behaves similar to the current insert operation in that it returns the defined record in the model.
    2- statusCode is evaluated internally today and that’s the number placed in the http status header
    3- 201 In the insert should also include A Location Header field with /newlycreatedID appended

    相关文章

      网友评论

          本文标题:数据库操作结果映射 http 状态码

          本文链接:https://www.haomeiwen.com/subject/puuwiftx.html