自定义内容类型

编程入门 行业动态 更新时间:2024-10-18 03:30:52
本文介绍了自定义内容类型-是否必须向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/vndpany.myapp-v1+json

或使用限定符

application/vndpany.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/vndpany.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/vndpany.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 ?

推荐答案

从 tools.ietf/html/rfc6838#section-3.2 不是强制性的,但是如果您拥有公开的API,则鼓励这样做.

From what I can read from tools.ietf/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 不需要供应商树 鼓励邮件列表进行审核,以提高的质量 这些规格.供应商树中的注册可能是 直接提交给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 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

更多推荐

自定义内容类型

本文发布于:2023-07-17 03:25:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1128956.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   类型   内容

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!