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 <zyli2...@gmail.com> wrote: > 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 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': >> MyAsynHttpConsumer to ProtocolTypeRouter() >> >> async_http_urlpatterns = [ >> url(r'^async-http/$', consumers. MyAsynHttpConsumer ), >> ] >> >> ProtocolTypeRouter ( >> 'http': AuthMiddlewareStack( >> URLRouter( >> my_channels_app.routing.async_http_urlpatterns >> ) >> ), >> ) >> >> Thanks >> Drew >> >> >> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/8c46871d-6e24-47e1-8813-5721014aedca%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/8c46871d-6e24-47e1-8813-5721014aedca%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFwN1uopgpGn7uASW0%2BteonKN8qQFdBXcwA2N8_JM1-CTYiDdg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.