什么是日期的版本一个REST API作为Twilio做有什么好处? [英] What is the benefit of versioning a REST api by date as Twilio does?

查看:217
本文介绍了什么是日期的版本一个REST API作为Twilio做有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我认为这是一个好主意版本的REST API。这就是常识。通常你满足如何做到这两种方法:

Basically, I think it's a good idea to version your REST api. That's common sense. Usually you meet two approaches on how to do this:


  • 要么,你有你的网址版本标识符,如 / API / V1 /富/条

  • 或者,您可以使用一个头,如接受:vnd.myco + V1

  • Either, you have a version identifier in your url, such as /api/v1/foo/bar,
  • or, you use a header, such as Accept: vnd.myco+v1.

到目前为止,一切都很好。这是几乎所有的大公司做。两种方法各有利弊,和大量的这种东西是这里讨论

So far, so good. This is what almost all big companies do. Both approaches have their pros and cons, and lots of this stuff is discussed here.

现在我已经看到了一个完全不同的方法,在Twilio,描述这里。他们使用日期:

Now I have seen an entirely different approach, at Twilio, as described here. They use a date:

在编译时,开发商包括应用程序的时间戳时,code编译的。该时间戳云中的所有HTTP请求。​​

At compilation time, the developer includes the timestamp of the application when the code was compiled. That timestamp goes in all the HTTP requests.

在请求进入Twilio,他们做了抬头。基于时间戳,他们确定是有效的这个code创建时和API相应路线

When the request comes into Twilio, they do a look up. Based on the timestamp they identify the API that was valid when this code was created and route accordingly.

这是一个非常聪明和有趣的方法,虽然我认为这是一个有点复杂。它可以是混乱了解时间戳是编译时间或时间戳当API发布,例如。

It's a very clever and interesting approach, although I think it is a bit complex. It can be confusing to understand whether the timestamp is compilation time or the timestamp when the API was released, for example.

现在,而我有点觉得这很聪明,以及,我不知道这种方法的真正好处。当然,这意味着你只需要记录您的API的一个版本(目前1),但在另一方面,它使得发生了什么变化更难以跟踪。

Now while I somehow find this quite clever as well, I wonder what the real benefits of this approach are. Of course, it means that you only have to document one version of your API (the current one), but on the other hand it makes traceability of what has changed more difficult.

有谁知道这种方法的优点是,为什么Twilio决定这样做?

Does anyone know what the advantages of this approach are, so why Twilio decided to do so?

请注意,我知道这个问题听起来好像答案(S)是主要基于舆论,但我想这Twilio有一个很好的技术理由这样做。所以,请不要关闭这个问题作为primariliy意见为基础的,因为我希望答案是没有。

推荐答案

有趣的问题,+ 1,但是从我所看到的,他们只有两个版本: 2008-08-01 2010-04-01 。所以从我的角度来看,这只是另一种方式来拼写 V1 V2 ,所以我不认为有一个技术上的原因,仅仅是preference。

Interesting question, +1, but from what I see they only have two versions: 2008-08-01 and 2010-04-01. So from my point of view that's just another way to spell v1 and v2 so I don't think there was a technical reason, just a preference.

这是所有我能找到自己的决定: https://news.ycombinator.com/项目?ID = 2857407

This is all I could find on their decision: https://news.ycombinator.com/item?id=2857407

编辑:请务必阅读下面的意见,其中@kelnos和@andes提及使用这种方法来版本的API的优势

make sure you read the comments below where @kelnos and @andes mention an advantage of using such an approach to version the API.

这篇关于什么是日期的版本一个REST API作为Twilio做有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆