自定义内容类型-是否必须向IANA注册? [英] Custom content type - is registering with IANA mandatory?

查看:180
本文介绍了自定义内容类型-是否必须向IANA注册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尽可能地开发RESTful API(尽管未满足HATEOAS约束,因此不是 REST API 本身)

I'm developing an API as RESTful as possible (though the HATEOAS constraint is not met thus it is not a REST API per se)

我正在对API进行版本控制,并且由于有多种方法可以做到这一点,所以我想我将使用Accept标头.我确实知道其他方法,但是这个问题的目的不是找到一种合适的方法来对API进行版本控制.

I'm versioning the API, and since there are several ways to do this, I think I'm going to use the Accept header. I do know the alternatives, but the purpose of this question is not to find a suitable way to version the API.

据我所知,有两种方法可以使用Accept标头对API进行版本控制,如此处此处此处:

As far as I know, there are two ways to version API using the Accept header, as seen here, here and here:

application/vnd.company.myapp-v1+json

或使用限定符

application/vnd.company.myapp+json;v=1

虽然这很清楚,但我了解所有x-自定义内容类型均已已弃用vnd.内容类型必须在IANA上注册.

While this is quite clear, I understood that all x- custom content types have been deprecated and vnd. content types have to be registered with IANA.

该API并非公开,也不会公开,使用该API的所有客户端都是内部开发的.

The API is not and will not be public, all the clients using it are developed internally.

正在注册自定义vnd.强制使用IANA的内容类型?如果未注册内容类型会怎样? 即使不向IANA注册,也可以简单地使用Accept标头application/vnd.company.myapp+json;v=2吗?

Is registering a custom vnd. content type with IANA mandatory? What happens if the content type is not registered? Can I simply use Accept header application/vnd.company.myapp+json;v=2 even without registering it with IANA?

由于仅出于版本控制目的,我需要自定义内容类型进行内容协商,因此我可以使用application/json;v=2之类的限定符吗?

Since I need a custom content type for content negociation purely for versioning purposes, can I use qualifier such as application/json;v=2 ?

推荐答案

From what I can read from https://tools.ietf.org/html/rfc6838#section-3.2 it is not mandatory, however if you have and API that is public it is encouraged to do so.

RFC6838是关于注册新的MIME/媒体类型的,带有以下文本,对于私有API(产品)来说似乎不是问题

RFC6838 is about registering new MIME/Media Types, with the following text it doesn't seem to be a problem for private API (product)

供应商树用于与公开关联的媒体类型
可用产品.

The vendor tree is used for media types associated with publicly
available products.

就像我说的那样,公共API(产品)也不需要它.

Also it is not required for the public API (product), like I said it is encouraged.

要公开曝光并审查要注册的媒体类型
使用media-types@iana.org
不需要供应商树 鼓励邮件列表进行审核,以提高
的质量 这些规格.供应商树中的注册可能是
直接提交给IANA,他们将在此接受专家审核 [RFC5226]待批准

While public exposure and review of media types to be registered in
the vendor tree are not required, using the media-types@iana.org
mailing list for review is encouraged, to improve the quality of
those specifications. Registrations in the vendor tree may be
submitted directly to the IANA, where they will undergo Expert Review [RFC5226] prior to approval

这篇关于自定义内容类型-是否必须向IANA注册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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