Questions tagged [actix-web]

488 questions
4
votes
1 answer

"Urlencoded payload size is bigger than allowed (default: 256kB)"

I have a small Rust program that formats MySQL queries, but I found it failing on bigger queries, returning Urlencoded payload size is bigger than allowed (default: 256kB) I'm using actix web, which looks like this use actix_web::{ web, App,…
Brian Leishman
  • 8,155
  • 11
  • 57
  • 93
4
votes
1 answer

How do I convert an async / standard library future to futures 0.1?

I want to use the async function to parse the inbound stream progressively, but actix-web requires impl Future as the return value. How can I convert the future returned by async function to what actix-web…
Mr.Wang from Next Door
  • 13,670
  • 12
  • 64
  • 97
4
votes
1 answer

How to execute an async function in actix-web?

There is an async connect() function as below. use actix_web::client::Client; use futures::compat::Future01CompatExt; use futures::future::{FutureExt, TryFutureExt}; pub async fn connect() { let request =…
Mr.Wang from Next Door
  • 13,670
  • 12
  • 64
  • 97
4
votes
4 answers

Error "BlockingClientInFutureContext" when trying to make a request from within an actix-web route handler function

I am writing a web service with Rust 2018 Stable and Actix-Web. Using Reqwest, I am making an HTTP request to a diffent site from within one route handler function. Simplyfied it looks like this extern crate reqwest; use actix_web; use…
C14L
  • 12,153
  • 4
  • 39
  • 52
4
votes
2 answers

How do I modify the response body in an actix-web 1.0 middleware?

I'd like to modify the response body in Actix-Web. I've implemented the v1.0.0 middleware but I've not been successful in changing the response body so far. I've tried two basic approaches: return a new ServiceResponse and use the method chains on…
Chris McKenzie
  • 3,681
  • 3
  • 27
  • 36
4
votes
1 answer

Save File with original filename when using the actix-web-Framework to upload a File on a webserver in Rust

I'm creating a webserver in Rust using the actix-web Framework. Currently I'm working on the Fileupload and for this im using actix-multipart. In the official Actix-Documentation there is an example for it: use std::cell::Cell; use std::fs; use…
Samuel Dressel
  • 1,181
  • 2
  • 13
  • 27
3
votes
2 answers

error[E0277]: the trait bound `FieldAttr: ToTokens` is not satisfied

I want to deploy a Dockerfile build on EC2(fargate). I got the following error in cloudwatch. 'Failed to create pool.: Error (None)' I have come up with a solution to this problem. I change method from build to build_unchecked in…
MrSmail
  • 43
  • 4
3
votes
1 answer

How to add a route to actix web only if external condition is met

I need to add a route to actix_web only if an external condition is met. Since actix_web's App uses a builder pattern and each call to App::route consumes the app instance, I can't seem to find a reasonable way of adding a route…
Markus
  • 2,412
  • 29
  • 28
3
votes
1 answer

actix: cannot start server service 0

I have the following main function (CORS is there since I'm using actix to serve a public API): use actix_cors::Cors; use anyhow::Result; use actix_web::{App, HttpServer}; #[actix_web::main] async fn main() -> Result<()> { HttpServer::new(||…
LeoDog896
  • 3,472
  • 1
  • 15
  • 40
3
votes
1 answer

How can I instrument async-graphql functions with tracing?

Copying the starwars example for actix-web I'm having issues understanding these errors when trying to instrument: #[derive(Debug)] // adding this struct AppState { gql_schema: Schema, // errors here…
Fred Hors
  • 3,258
  • 3
  • 25
  • 71
3
votes
1 answer

Is there a way to split server routes declaration in actix-web?

I have the following server declaration right now let server = HttpServer::new(move || { App::new() .app_data(actix_web::web::Data::new(pool.clone())) .service(ping) .service(stock::controller::get_all) …
nxyt
  • 113
  • 5
3
votes
1 answer

Idiomatic way to handle errors with an early return in Rust

I currently have the below code to handle the case where I want to handle an error without propagation or continue the function. The use case for this is a web server controller, where I would prefer to manual handle possible errors - which is why…
JamesGill
  • 183
  • 11
3
votes
0 answers

How to solve "implementation of `sqlx::Acquire` is not general enough"

I'm creating a actix_web app. I tried to spawn a new task and use functions, which are already in use in actix_web part. But if I compile, I see following error with some life-time information. To be honest, I've no idea what to do with this…
macalloy
  • 43
  • 7
3
votes
1 answer

How to use middleware on actix web 4?

I am trying to use a simple Middleware with ActixWeb 4: HttpServer::new( move || { let app_state = AppState { db_helper: external_db.clone(), client: Client::new(), }; App::new() …
Kingfisher Phuoc
  • 8,052
  • 9
  • 46
  • 86
3
votes
2 answers

Blocked by CORS on Actix Web backend with Cors::permissive()

I'm trying to build out a simple backend with Rust, but I keep running into a CORS error. My react frontend says: Access to XMLHttpRequest at 'http://127.0.0.1:3002/auth' from origin 'http://localhost:3000' has been blocked by CORS policy: No…
Caio Ishikawa
  • 179
  • 11