Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ module.exports.lambdaHandler = function(event, context, callback) {
// Check the type
req.is('html') // false

// Get an AWS API Gateay requestContext property
// Get an AWS API Gateway requestContext property
req.context('requestId') // '08e3e2d0-daca-11e6-8d84-394b4374a71a'

// Get the unmodified Lambda Proxy event
req.getLambdaEvent()
}
```

Expand Down
9 changes: 9 additions & 0 deletions src/events/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ class Request {
return this.headers[field.toLowerCase()]
}

/**
* Returns the unmodified Lambda Proxy Event
*
* @returns {object} - Lambda event
*/
getLambdaEvent () {
return this.rawLambdaEvent
}

/**
* Returns true if the incoming request’s “Content-Type” HTTP header field matches the MIME type
* specified by the type parameter. Returns false otherwise.
Expand Down
6 changes: 6 additions & 0 deletions test/events/request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,11 @@ describe('events', () => {
expect(req.context('requestId')).to.eq('08e3e2d0-daca-11e6-8d84-394b4374a71a')
})
})

describe('#getLambdaEvent', () => {
it('should return the raw lambda event', () => {
expect(new Request(lambdaEvent).getLambdaEvent()).to.eq(lambdaEvent)
})
})
})
})