Skip to content

How to: Http request #415

Answered by nmoutschen
Chandrian asked this question in Q&A
Feb 10, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @Chandrian!

There shouldn't be any difference whether or not you're running this code in a Lambda function. What version of Rust/Cargo are you currently using?

I'm thinking that you might be using an older version of Rust that cannot properly infer that reqwest::Response is safe to use since StatusCode implements Copy.

For reference, I wrote a small Lambda function using your code and I can compile it without any problem, using version 1.58.1:

use reqwest::{Client, StatusCode};
use lambda_runtime::{Context};

type Error = Box<dyn std::error::Error + Send + Sync>;

#[tokio::main]
async fn main() -> Result<(), Error> {
    lambda_runtime::run(lambda_runtime::handler_fn(my_handler)).await?;

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Chandrian
Comment options

Answer selected by Chandrian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants