GithubHelp home page GithubHelp logo

nationalholidays's Introduction

国家法定节假日API


DEMO访问地址:DEMO

API 设计理念

参考arccode的API设计规范,在此基础上做了相应修改。

  1. 将涉及的实体抽象成资源,即按 id 访问资源

  2. 使用 HTTP 动词对资源进行 CRUD(增删改查):

    GET -> 查, POST -> 增, PUT -> 改, DELETE -> 删

  3. URL 命名规则,对于资源无法使用一个单数名词表示的情况,我使用下划线 _ 连接

    资源采用名词命名,e.g:节假日 -> holiday

    新增节假日 url -> /holiday, verb -> POST

    修改节假日 url -> /holidays/{id}, verb -> PUT

    节假日详情 url -> /holidays/{id}, verb -> GET

    删除节假日 url -> /holidays/{id}, verb -> DELETE

    节假日列表 url -> /holidays, verb -> GET

  4. API URL中增加版本号,如:

    v1版本:

    GET https://url/api/v1/nationalholidays/cn/2017

    v2版本:

    GET https://url/api/v2/nationalholidays/cn/2017

JSON 结构

requestParams:

{

}

responseBody:

{
"meta": {
    
    },
"data": {
    
    }
}

meta:

{
    "code": 200,
    "msg":  "创建成功"
}

meta 中封装操作成功或失败的消息,data 中封装返回的具体数据。

nationalholidays's People

Contributors

qdlake avatar

Watchers

 avatar  avatar

Forkers

conkeyn lindent

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.