zoukankan      html  css  js  c++  java
  • restful 规范

    接口

    1.根据method不同,进行不同操作

      GET/POST/PUT/DELETE/PATCH

    2.面向资源编程

      http://www.luffycity.com/salary

    3.提现版本

      建议用:

      http://www.luffycity.com/v1/salary

      http://www.luffycity.com/v2/salary

      不建议用:

      http://www.luffycity.com/v1/salary

      http://www.luffycity.com/v2/salary

    4. 体现是API

      http://www.luffycity.com/api/v1/salary

      http://www.luffycity.com/api/v2/salary

      http://api.luffycity.com/v1/salary

      http://api.luffycity.com/v2/salary

    5.https

      http://www.luffycity.com/api/v1/salary

      http://www.luffycity.com/api/v2/salary

    6.响应式设置状态码

      200

      300

      400

      500

      return HttpResponse("adfasdf",status=300)

    7.条件

      https://www.luffy.com/apiv2/salary?page=1&size=10

    8.返回值

      https://www.luffy.com/api/v2/salary

      GET:

        [

          {"id":1,"title":"高亮"},

          {"id":2,"title":"龙泰"},

          {"id":3,"title":"小东北"}

        ]

      POST:返回新增的数据

        {"id":1."title":"高亮"}

      https://www.luffycity.com/api/v2/salary/1/

      GET:获取单条数据

        {"id":1."title":"高亮"}

      PUT:更新

        {"id":1."title":"高亮"}

      PATCH:局部更新

        {"id":1."title":"高亮"}

      DELETE:删除

    9.返回错误信息

      {

        code:100001,

        error:"xxx错误"

      }

    10. Hypermedia API

      ret={

        code:1000,

        data:{

          id:1,

          name:"小强",

          depart__id:http://www.luffycity.com/api/v1/depart/8/

          }

         }

  • 相关阅读:
    出错处理函数abort、exit、atexit、strerror. . .
    linux查询系统信息命令
    [转载]比google和百度强十倍的搜索类网站
    陶  朱  商  经
    ip的划分,超详细.【网管常识】
    linux的hostname修改详解
    勤于寻找谈话资料
    Windows常用命令集
    C语言中printf格式
    How to disable SELinux
  • 原文地址:https://www.cnblogs.com/pengpengge/p/9683483.html
Copyright © 2011-2022 走看看