Whats the advantage of using a package to create a RESTful API interface

泄露秘密 提交于 2019-12-25 01:35:02

问题


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

I've looked at:

  • 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

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?

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.

Thanks


回答1:


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:

  • 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

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.



来源:https://stackoverflow.com/questions/8452686/whats-the-advantage-of-using-a-package-to-create-a-restful-api-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!