从 pydoc 创建 HTTP 客户端
项目描述
*******
Doclink
*******
.. 图片:: https://travis-ci.org/Luoyufu/doclink.svg?branch=master
:target: https://travis-ci. org/Luoyufu/doclink
.. 图片:: https://codecov.io/gh/Luoyufu/doclink/branch/master/graph/badge.svg
:target: https://codecov.io/gh/Luoyufu/doclink
. . 图片:: https://img.shields.io/pypi/v/doclink.svg
:target: https://pypi.python.org/pypi/doclink
.. 图片:: https://img.shields. io/pypi/pyversions/doclink.svg
:目标:https: //pypi.python.org/pypi/doclink
| 从 pydoc 为 Web API 构建客户端。灵感来自`Uplink <https://github.com/prkumar/uplink>`_。
概述
========
| Doclink 通过编写 pydoc 来声明 api 元数据,将 Python 函数转换为 HTTP API。
| 它基于 Requests 并使用带有预定义模式的 YAML 作为 api 声明。
| 调用该函数时,来自 HTTP API 的响应将作为参数传入,以供进一步处理。
特性
========
* 使用 **pydoc** 创建 python 函数作为 HTTP API
* **YAML** 基于架构的 api 声明
* 在 **same** 函数中处理 api 响应
* 响应挂钩 * *middleware**
* **all** args for Requests supported
* select base_uri dynamic from simple **router**
Quick through, with httpbin
=====
创建一个消费者实例。
.. 代码块:: python
from doclink import Consumer
consumer = Consumer('http://httpbin.org/')
添加响应钩子(中间件)。
.. code-block:: python
@consumer.resp_hook
def json_hook(resp):
resp.json = resp.json()
添加api声明函数。
.. code-block:: python
@consumer.get('get')
def get(resp):
"""
<meta>
args:
query:
- arg1: arg1
- arg2: arg2
</meta>
"""
return resp .json['args']
使用你的 api。
>>> get()
{
"arg1": "arg1",
"arg2": "arg2"
}
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
doclink-1.1.0.tar.gz
(10.5 kB
查看哈希)
内置分布
doclink-1.1.0-py2.py3-none-any.whl
(16.3 kB
查看哈希)