Skip to content

LambdaRequest Accessibility #92

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

Closed
dbettin opened this issue Mar 2, 2019 · 6 comments · Fixed by #93
Closed

LambdaRequest Accessibility #92

dbettin opened this issue Mar 2, 2019 · 6 comments · Fixed by #93

Comments

@dbettin
Copy link

dbettin commented Mar 2, 2019

Are there any disadvantages to making lambda_http::LambdaRequest public?

For testing http handlers, I would like to deserialize json to a http::Request

I am essentially after performing something akin to https://github.com/awslabs/aws-lambda-rust-runtime/blob/master/lambda-http/src/request.rs#L361.

@davidbarsky
Copy link
Contributor

@dbettin Not really? We merged #85 a few days ago, but didn't actually release it on crates.io—you should be able to take a git dependency on it and rely on it on test code.

@softprops
Copy link
Contributor

@dbettin thanks for reaching out.

There are good reasons for not making private interfaces public. It makes it possible to change without breaking application code. Depending on what your specific usecase is, there may be alternative ways of enabling what your trying to accomplish and still keep implementation details private.

Can you walk me through your use case in more depth?

As mentioned above, it's currently possible ( on master ) to construct full http requests using http crate builder methods and lambda http request ext methods.

@dbettin
Copy link
Author

dbettin commented Mar 3, 2019

@softprops thanks for the response.

I am quite aware of the general principle of information hiding. I am more interested in why this specific struct is not public.

Our use case: we are calling our lambdas locally when developing and would like to pass in a file with json as the event. This works well with non-http lambdas but it is not trivial if we would like to take advantage of the lambda http crate.

A public LambdaRequest struct makes this a breeze.

Thanks!

@softprops
Copy link
Contributor

softprops commented Mar 3, 2019

I'm thinking an interface that would just look like a func exposed that took in some bytes and returned the request, similar to serde's from_xxx functions would satisfy the need without leaking internal impl details.

Would a lambda_http::request::from_str(loaded_from_disk) fn work for you?

@softprops
Copy link
Contributor

The reason why the struct is not public is because its an implementation detail. It's only intended as an intermediary to get to the http interface. It's not meant to be a public interface.

@dbettin
Copy link
Author

dbettin commented Mar 3, 2019

@softprops That would work great!

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