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/

          }

         }

  • 相关阅读:
    Android中Chronometer 计时器和震动服务控件
    Android中几种常用的话框
    Android通过长按图片设置为壁纸
    Android把图片保存到SQLite中
    激活Win10
    SQL 语句解决实际问题
    在Foxmail邮件客户端登录263企业邮箱
    Visual Studio 安装VS10x CodeMAP
    开发常见问题汇总
    Java笔记:编写第一个Java程序
  • 原文地址:https://www.cnblogs.com/pengpengge/p/9683483.html
Copyright © 2011-2022 走看看