Giter VIP home page Giter VIP logo

actix_lambda_http's People

Contributors

yvt avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dspatoulas

actix_lambda_http's Issues

thread 'main' panicked at 'no Task is currently running'

screenshot-2019-08-06-21-58-56

Hi, thank you for your excellent package.
I experienced panic when using this with async handlers.

Here is a minimal example.

#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate log;
extern crate simple_logger;

use actix_lambda_http;
use actix_web::{web, App, Error, HttpResponse};
use futures::future::{ok, Future};
use hyper::{Client, Uri};
use lambda_http::{lambda, IntoResponse, Request, RequestExt, Response};
use lambda_runtime::error::HandlerError;
use lambda_runtime::Context;
use tokio;
use tokio::prelude::AsyncWrite;
use tokio::runtime::Runtime;

fn async_index() -> Box<dyn Future<Item = String, Error = Error>> {
    let client = Client::new();
    let fut = client
        .get(Uri::from_static("http://httpbin.org/ip"))
        .map(|res| {
            format!("status: {}, body: {:?}", res.status(), res.body())
        })
        .map_err(|err| eprintln!("IO error: {:?}", err));
    Box::new(fut.from_err())
}

fn main() {
    env_logger::init();

    actix_lambda_http::LambdaHttpServer::new(|| {
        App::new()
            .wrap(actix_web::middleware::Logger::default())
            .service(
                web::scope("/test-rust")
                    .route("/", web::to_async(async_index)),
            )
    })
    .binary_media_types(vec!["image/png"])
    .start()
    .unwrap();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.