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

Examples and invoke don't work together #678

Closed
alper opened this issue Jul 21, 2023 · 3 comments
Closed

Examples and invoke don't work together #678

alper opened this issue Jul 21, 2023 · 3 comments

Comments

@alper
Copy link

alper commented Jul 21, 2023

I'm a bit confused that al the examples don't really work with each other: it's a name, firstName and a command parameter.

That much is fine, but the invoke command:

curl -v -X POST 'http://127.0.0.1:9001/lambda-url/rustfun/' -H 'content-type: application/json' -d '{ "name": "alper" }'

Doesn't come out this side:

let who = event
        .query_string_parameters_ref()
        .and_then(|params| params.first("name"))
        .unwrap_or("world");

query_string_parameters here is empty. The stuff passed here ends up in the body of the event. Do I need to lift the body and parse it myself or is there some way to make this code work?

I'm firing a curl here because when I do: cargo lambda invoke rustfun -p 9001 --data-ascii '{ "name": "hi" }'

I get:

error sending request for url (http://[::1]:9001/2015-03-31/functions/rustfun/
  │   invocations): error trying to connect: tcp connect error: Connection refused
  │   (os error 61)

Where it adds a random date to the URL which I can't get out of there.

@calavera
Copy link
Contributor

calavera commented Jul 24, 2023

When you invoke an HTTP function using cURL, the content for the flag -d is the body in the HTTP request. If you want to send query parameters, you can add them to the URL, like this curl http://127.0.0.1:9001/lambda-url/rustfun/\?name=alper.

I'm firing a curl here because when I do: cargo lambda invoke rustfun -p 9001 --data-ascii '{ "name": "hi" }'

error sending request for url (http://[::1]:9001/2015-03-31/functions/rustfun/
  │   invocations): error trying to connect: tcp connect error: Connection refused
  │   (os error 61)

Which version of Cargo Lambda are you using? It sounds like you bumped into this issue, which was fixed in recent versions: cargo-lambda/cargo-lambda#452

@calavera
Copy link
Contributor

I'm closing this issue since there is nothing to resolve here. Let us know if you have any other questions.

@calavera calavera closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for the maintainers of this repository to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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

No branches or pull requests

2 participants