piston-在django中实现REST风格的API
2013-02-25 22:22
597 查看
转自:http://www.cnblogs.com/emotion164/archive/2012/02/19/2358738.html
先说说我对REST的理解,在REST之前,web service的设计方法主流应该是SOAP,我觉得SOAP一定是那些搞C++/C#的人设计出来的,因为SOAP思考问题的着眼点是如何把之前已有的系统搬到web上去。而REST的理念更有方法论的味道,更贴合web应用的实际。
关于REST的介绍,推荐下面这篇文章:
http://www.xml.com/pub/a/2004/12/01/restful-web.html
就像文章里说的,为你的web应用设计REST风格的API,只要思考并回答以下4个问题:
What are the URIs? (everything in your system is resource, and every resource should have a URI)
What's the format? (how to represent your resource? 1. how to define it 2. return format, xml, json or ...? )
What methods are supported at each URI? (CRUD)
What status codes could be returned?
那么以上4点,piston基本能帮你搞定2,3,4。除此之外,piston还有的功能:
1. 自定义对每个resource的访问权限。 非常有用!
2. 以Emitters的方式支持多种数据格式(xml,json),用户也可自定义。并可以根据请求参数动态选择
3. 对资源的访问流量控制
piston的文档:
https://bitbucket.org/jespern/django-piston/wiki/Documentation
先说说我对REST的理解,在REST之前,web service的设计方法主流应该是SOAP,我觉得SOAP一定是那些搞C++/C#的人设计出来的,因为SOAP思考问题的着眼点是如何把之前已有的系统搬到web上去。而REST的理念更有方法论的味道,更贴合web应用的实际。
关于REST的介绍,推荐下面这篇文章:
http://www.xml.com/pub/a/2004/12/01/restful-web.html
就像文章里说的,为你的web应用设计REST风格的API,只要思考并回答以下4个问题:
What are the URIs? (everything in your system is resource, and every resource should have a URI)
What's the format? (how to represent your resource? 1. how to define it 2. return format, xml, json or ...? )
What methods are supported at each URI? (CRUD)
What status codes could be returned?
那么以上4点,piston基本能帮你搞定2,3,4。除此之外,piston还有的功能:
1. 自定义对每个resource的访问权限。 非常有用!
2. 以Emitters的方式支持多种数据格式(xml,json),用户也可自定义。并可以根据请求参数动态选择
3. 对资源的访问流量控制
piston的文档:
https://bitbucket.org/jespern/django-piston/wiki/Documentation
相关文章推荐
- piston-在django中实现REST风格的API
- 六步实现Rest风格的API
- 六步实现Rest风格的API
- 六步实现Rest风格的API
- 六步实现Rest风格的API
- 六步实现Rest风格的API
- 六步实现Rest风格的API
- Django REST风格接口实现匿名访问
- 六步实现Rest风格的API
- 【Python】调用百度REST API实现语音识别
- swagger + spring mvc 实现rest 接口代码与api 同步维护,更新
- API 网关设计 (Rest 风格)
- SpringMVC实现完整的REST风格的CRUD
- 使用NetKerne实现REST风格的ESB
- REST 风格的api
- 实现REST风格的简单小CURD程序总结注意事项
- Django-Rest-Framework 教程: 5. 提高关联性和超链接API
- Django rest framework API Guide的 Responses 翻译
- Yii2实现RESTful风格的API中要注意的坑
- tastypie Django REST API developement 1)