[Twisted-Python] How to design REST API with Twisted?

Mashiat Sarker Shakkhar mashiat.sarker at gmail.com
Tue Nov 3 21:09:29 MST 2015


On 11/3/15 10:15 PM, Wang Yan wrote:
>
> I'm planning to design some REST APIs with Twisted in Python. For 
> example, I want to use the HTTP method "GET" to fetch a single user's 
> information:
>
> |GET http://myhost:8000/api/v1.0/users/[user_id] |
> I know I should inherit the twisted.web.resource.Resource and 
> implement "getChild" by myself.
> The question is, should I implement a class for each segment of the 
> URI? If so, I have to implement class API, class V1, class Users and 
> Class User. In other words, if there're 10 segments in the URI, do I 
> have to implement 10 classes to represent those resources?

Twisted is too low-level for such use in my opinion. We use Klein 
(https://github.com/twisted/klein) which offers nice abstraction above 
Twisted.
I know this does not answer your question. Just wanted to make sure that 
you are aware of possible options.

-Shakkhar

[...]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20151103/968e5f7f/attachment-0002.html>


More information about the Twisted-Python mailing list