Features-特性(python-eve官方文档学习)

原文链接:http://python-eve.org/features.html

省略代码

----------------------------------------

Below is a list of main features that any EVE-powered APIs can expose. Most of these features can be experienced live by consuming the Demo API (see Live demo).

下面是基于eve的api能展示的功能特性列表,大部分特性可以在demo api中使用

Emphasis on REST  rest中的重点

The Eve project aims to provide the best possible REST-compliant API implementation. Fundamental REST principles like separation of concerns, stateless and layered system, cacheability, uniform interface have been kept into consideration while designing the core API.

eve程序目的是提供最佳的rest兼容api实现。像关注点分离,无状态,分层系统,可缓存,统一接口等基本rest原则,在设计核心api时都保证始终考虑到。

Full range of CRUD operations  所有crud操作

APIs can support the full range of CRUD operations. Within the same API, you can have a read-only resource accessible at one endpoint, along with a fully editable resource at another endpoint. The following table shows Eve’s implementation of CRUD via REST:

apis能支持全部的crud操作,同样的api,你可以在某个资源端点设置只读,而在另外一个资源端点设置完全可编辑,下面的表显示了eve的rest的curd实现。


Overriding HTTP Methods 覆盖http方法

As a fallback for the odd client not supporting any of these methods, the API will gladly honor X-HTTP-Method-Override requests. For example a client not supporting the PATCH method could send a POST request with a X-HTTP-Method-Override: PATCH header. The API would then perform a PATCH, overriding the original request method.

为了预防一些旧的客户端不支持某些http methods,api也支持X-HTTP-Method-Override请求,例如一个客户端不支持pathch,可以用X-HTTP-Method-Override: PATCH header发送一个post请求,api将会当做一个patch请求覆盖原本的请求方法。


Customizable resource endpoints 可定制的终端资源

By default, Eve will make known database collections available as resource endpoints (persistent identifiers in REST idiom). So a database people collection will be avaliable at the example.com/people API endpoint. You can customize the URIs though, so the API endpoint could become, say, example.com/customers/overseas. Consider the following request:

默认情况下,eve将数据库集合作为资源端点识别(在rest规范中的一贯方式),因此一个数据库people集合可以通过 axample.com/people api端点来访问,但是你可以自定义uris,所以api端点可以这样,example.com/customers/overseas,考虑下面的请求:

$ curl -i http://eve-demo.herokuapp.com/people HTTP/1.1 200 OK

The response payload will look something like this: 响应结果看起来像这样:


The _items list contains the requested data. Along with its own fields, each item provides some important, additional fields:

_items列表包含了请求的数据,除了本身的数据字段,每个item提供了一些重要的额外字段:

These additional fields are automatically handled by the API (clients don’t need to provide them when adding/editing resources).

这些附加的字段是自动被api处理添加的(客户端在添加或编辑资源时不需要操作它们)


The _meta field provides pagination data and will only be there if Pagination has been enabled (it is by default) and there is at least one document being returned. The _links list provides HATEOAS directives.

_meta属性提供分页数据,只有pagination启用才会出现,至少有一个文档返回,_links列表提供HATEOAS指令。


Sub Resources  子资源

However, such an auto-managed database will perform very poorly since it lacks indexes and any sort of optimization.


转载于:https://my.oschina.net/timluo/blog/345084

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值