Restful最佳实践

遵循规范

API版本控制

API版本控制有三种方式:
- 无版本控制
无版本控制,每次API的升级都写新的接口,不影响旧的。
- 版本控制

错误定义

遵循常规通用的错误定义

常规通用错误对照表

Response ClassHTTP Status CodeSymbol
消息100continue
101switching_protocols
102processing
成功200ok
201created
202accepted
203non_authoritative_information
204no_content
205reset_content
206partial_content
207multi_status
208already_reported
226im_used
重定向300multiple_choices
301moved_permanently
302found
303see_other
304not_modified
305use_proxy
306reserved
307temporary_redirect
308permanent_redirect
客户端错误400bad_request
401unauthorized
402payment_required
403forbidden
404not_found
405method_not_allowed
406not_acceptable
407proxy_authentication_required
408request_timeout
409conflict
410gone
411length_required
412precondition_failed
413request_entity_too_large
414request_uri_too_long
415unsupported_media_type
416requested_range_not_satisfiable
417expectation_failed
422unprocessable_entity
423locked
424failed_dependency
426upgrade_required
428precondition_required
429too_many_requests
431request_header_fields_too_large
服务端错误500internal_server_error
501not_implemented
502bad_gateway
503service_unavailable
504gateway_timeout
505http_version_not_supported
506variant_also_negotiates
507insufficient_storage
508loop_detected
510not_extended
511network_authentication_required
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值