请告诉我使用包的优势,创建一个RESTful API接口 [英] Whats the advantage of using a package to create a RESTful API interface

查看:134
本文介绍了请告诉我使用包的优势,创建一个RESTful API接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建我的应用程序的一个简单的RESTful接口和我一直在寻找什么是可用的在那里:

I am creating a simple RESTful interface on one of my apps and I have been looking at what's available out there:

我已经看了:

  • django-piston but it seems abandoned and the feedback on it is not great.
  • django-dynamicresponse which seems rather bare
  • A lot of packages from here

不过,着眼于如何这些包的例子似乎他们真的不提供太多。这真的不是很难创建URL映射列表,并使用类似simplejson返回响应...

However, looking at examples of how these packages it seems that they don't really provide much. It's really not that hard to create a list of URL mappings and use something like simplejson to return a response...

是否有优势,使用这些包,我很想念之一吗?

Is there an advantage to using one of these packages that I am missing?

这问题可能类似于 Django和RESTful API中的,但它一直以来一段时间一个有过任何新的答案,我想找出是否值得在所有使用的包。

This question may be similar to Django and Restful APIs but it has been a while since that one had any new answers, and I want to find out whether it is worth to use a package at all.

感谢

推荐答案

如果你正在写为内部使用的一个或两个简单的模型(例如,一个API,为您的应用程序的AJAX前端与后端VS沟通。暴露给外部客户端的API),然后框架,如Django的活塞或Tastypie可能会矫枉过正相比,写一个或两个视图并使用simplejson。

If you are writing one API for one or two simple models for "internal" use (eg, for the AJAX frontend of your app to communicate with the backend vs. an API exposed to external clients), then frameworks like django-piston or Tastypie might be overkill compared to writing one or two views and using simplejson.

当框架开始真正拉开自己的体重是当你有更复杂的要求。一些例子:

Where the frameworks start to really pull their own weight is when you have more complicated requirements. Some examples:


  • 您有很多的关系(认为嵌套的树形结构)
  • 一个复杂的模型
  • 您需要支持多个序列化(XML,YAML,Plist档案,或JSONP除了JSON)

  • 您想版本的API

  • 您想要做限制某些操作的访问(例如,提供只读某些客户端访问)

  • 您要节流或速率限制客户端访问

  • you have a complicated model with a lot of relations (think nested tree structures)
  • you need to support multiple serializations (XML, YAML, Plists, or JSONP in addition to JSON)
  • you want to version your API
  • you want to do restrict access for some operations (eg, to provide read-only access to certain clients)
  • you want to throttle or rate-limit client access

许多那些不在你控制两端,但变得非常重要,当你正在考虑让外部API来为您服务小型,简单的项目一个大问题。

Many of those aren't a big deal on a small, simple project where you control both ends, but become very important when you're thinking about making an external API to your service.

这篇关于请告诉我使用包的优势,创建一个RESTful API接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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