Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-30 Thread Andrew Godwin
You need to route by URL - see the example in the docs here, including how to fallback to Django views: https://channels.readthedocs.io/en/latest/topics/routing.html#urlrouter Andrew On Tue, Oct 30, 2018 at 5:05 AM Zhiyu (Drew) Li wrote: > Thanks! Another question it seems once I manually put '

Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-30 Thread Zhiyu (Drew) Li
Thanks! Another question it seems once I manually put 'http': MyAsyncHttpConsumer pair in the ProtocolRouter, all existing sync http views stopped running as their type is "http" as well. So how to do a mix of async HTTP and sync http? Thanks Drew On Mon, Oct 29, 2018, 23:15 Andrew Godwin wrote:

Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-29 Thread Andrew Godwin
Yup, that's the right way - subclass the async consumer class and then write a handle method. You have to do your own post/get distinctions, like in a Django view, but with the scope rather than the request. Andrew On Mon, Oct 29, 2018 at 4:37 PM Zhiyu/Drew Li wrote: > Not sure if this is the b

Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-29 Thread Zhiyu/Drew Li
Not sure if this is the best way. I just found inside AsyncHttpConsumer.handle() I can access self.scope['method'] to determine if it is a GET or POST or others. Thanks Drew On Monday, October 29, 2018 at 3:50:43 PM UTC-6, Zhiyu/Drew Li wrote: > > Hi there, > > Newbie to Channels. > > I am

How to subclass AsyncHttpConsumer for a GET request?

2018-10-29 Thread Zhiyu (Drew) Li
Hi there, Newbie to Channels. I am trying to write a Async consumer to handle a http GET request How to write a subclass MyAsynHttpConsumer(AsyncHttpConsumer) for this purpose? Or I am looking at the wrong class? Also if I understand correctly, I should manually add a new pair 'http': MyAsynHttp