Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[reply-functions] Add support to use functions in reply functions #42

Merged
merged 1 commit into from Apr 8, 2020

Conversation

jonathansamines
Copy link
Contributor

Some times it is useful to construct responses (body and headers) based on the incoming http request information. This pull request add support for it by allowing to specify functions on both arguments to the .reply() function.

I tried to add test cases for both scenarios, but please let me know if additional tests are required.

Thanks for the amazing library!

Copy link
Owner

@mmalecki mmalecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the contribution, and I'm very glad you like hock!
Will release a new version shortly.

hockInstance
.get('/url?key=value')
.reply(200, function(request) {
const query = url.parse(request.url, true).query;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL url.parse accepts the second parameter, neat!

@mmalecki mmalecki merged commit dc07410 into mmalecki:master Apr 8, 2020
@mmalecki
Copy link
Owner

mmalecki commented Apr 8, 2020

Published as 1.4.1 🎉

@jonathansamines
Copy link
Contributor Author

Thanks, will start using it right away!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants