示例#1
0
def lambda_handler(event, context=None):

    # Periodic
    if event.get('detail-type') == 'Scheduled Event':
        debug(event, context)
        return app.on_timer(event)

    # SNS / Dynamodb / Kinesis
    elif event.get('Records'):
        records = event['Records']
        if records and records[0]['EventSource'] == 'aws:sns':
            return app.on_config_message(records)
        else:
            return debug(event, context)
    elif not event.get('path'):
        return debug(event, context)

    # API Gateway
    if app.config.get('sentry-dsn'):
        from raven import Client
        from raven.contrib.bottle import Sentry
        client = Client(app.config['sentry-dsn'])
        app.app.catchall = False
        wrapped_app = Sentry(app.app, client)
    else:
        wrapped_app = app.app

    return wsgigw.invoke(wrapped_app, event)
示例#2
0
def lambda_handler(event, context=None):

    # Periodic
    if event.get('detail-type') == 'Scheduled Event':
        debug(event, context)
        return app.on_timer(event)

    # SNS / Dynamodb / Kinesis
    elif event.get('Records'):
        records = event['Records']
        if records and records[0]['EventSource'] == 'aws:sns':
            return app.on_config_message(records)
        else:
            return debug(event, context)
    elif not event.get('path'):
        return debug(event, context)

    # API Gateway
    if app.config.get('sentry-dsn'):
        from raven import Client
        from raven.contrib.bottle import Sentry
        client = Client(app.config['sentry-dsn'])
        app.app.catchall = False
        wrapped_app = Sentry(app.app, client)
    else:
        wrapped_app = app.app

    return wsgigw.invoke(wrapped_app, event)