Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

# -*- coding: utf-8 -*- 

""" 

Pyramid plugin to receive, parse, and dispatch Sendgrid Webhook events 

 

To use this app, add a configuration statement with your intended webhook 

callback path: 

 

    config.include('pyramid_sendgrid_webhooks', '/sendgrid/webhooks') 

 

Then, set up subscribers for any events that you want to be notified of: 

 

    from pyramid_sendgrid_webhooks import events 

 

    def handle_bounce(event): 

        request = event.request 

        print event.reason 

 

    ... 

    config.add_subscriber(handle_bounce, events.BounceEvent) 

""" 

 

from . import parser 

 

__author__ = 'Kyle Stark' 

__email__ = 'kyle@goodrx.com' 

__version__ = '0.1.0' 

 

 

def receive_events(request): 

    for event in parser.webhooks_from_request(request): 

        request.registry.notify(event) 

    return request.response 

 

 

def includeme(config): 

    """ 

    Adds route and view configuration 

    """ 

    config.add_route('sendgrid-webhook-receive', '/receive') 

    config.add_view(receive_events, route_name='sendgrid-webhook-receive')