Questions tagged [actix-web]
488 questions
5
votes
1 answer
How do I create a stream for actix-web HttpResponse to send a file chunk by chunk?
I want to stream a encrypted file with actix-web in Rust. I have a loop that decrypts the encrypted file chunk by chunk using sodiumoxide. I want to send the chunks to the client.
My loop looks like this:
while stream.is_not_finalized() {
match…

bmx
- 61
- 1
- 2
5
votes
1 answer
How to get (binary) payload from actix_web::HttpRequest
I'm writing some web api in Rust. I send Unit8Array from JavaScript with XMLHttpRequest, and I need to read them in server as Bytes.
Declaration of my service method is:
pub fn user_login_bin(mut req: HttpRequest) {
println!("{:?}", req);
let mut…

Piotr Płaczek
- 530
- 1
- 8
- 20
5
votes
1 answer
How can I fix "AsyncFactory<_, _> is not implemented" error in Actix-Web?
This is my code. I'm trying to get posts from the Rust subreddit. I would be using Actix's built in client, but it's not working on Windows, hence the use of reqwest instead:
[dependencies]
actix-web = "1.0.8"
futures = "0.1.29"
reqwest =…

Rokit
- 977
- 13
- 23
5
votes
2 answers
Catch GET & POST requests from HTML page using actix-web
I am getting an error message when submitting HTML form in order to catch the requested details inside FORM (I am using actix-web).
When I submit the FORM, I am getting this error:
Content type error
The code used:
#[derive(Deserialize)]
struct…

Cliff Anger
- 195
- 2
- 11
5
votes
2 answers
HTTP request inside actix-web handler -> Multiple executors at once: EnterError
When creating a hyper post request inside an actix-web resolver, the following error is thrown - how can one send one a http request by spawning the request into the existing executor?
thread 'actix-rt:worker:1' panicked at 'Multiple executors at…

Techradar
- 3,506
- 3
- 18
- 28
4
votes
1 answer
How to use actix-redis session in async-graphql resolvers
I am trying to use session object with Redis as the storage in a distributed system in the signin, signup and signout resolvers to set and delete session for userid but having issues with that because actix' Session does not implement Send and…

Oyelowo
- 41
- 4
4
votes
2 answers
How to use actix_web::client::Client in Actix-web 4.0
I use crate scylla that use tokio 1, so i must use crate actix-web 4.0 beta.
Now i have problem that use actix_web::client::Client show error :
3 | use actix_web::client::Client;
| ^^^^^^ could not find `client` in `actix_web`
i…

Pamungkas Jayuda
- 1,194
- 2
- 13
- 31
4
votes
1 answer
Returning an unauthorized response in actix-web middleware in Rust
I have dove into the wonderful world of Rust and the Actix-Web the past few weeks and I am working on building various types of authentication through a piece of actix-web middleware. I have all of the auth logic completely figured out, but I cannot…

CivAsnem
- 41
- 2
4
votes
2 answers
How to modify request data in actix-web middleware?
Is there a recommended way of modifying the request received on actix-web? I am looking for way to add data to the request object and have it available for processing by downstream middlewares and handlers.
The Middleware documentation…

Allan K
- 379
- 2
- 13
4
votes
1 answer
actix_web How to get the response body from awc::client::ClientResponse
I am trying to get the response out of the awc::client::ClientResponse. But always get the empty string. If I use the same request with curl I get the response.
Here is what I am trying This is a actix_web service which accepts the json request and…

presci
- 353
- 1
- 2
- 12
4
votes
1 answer
How to print a response body in actix_web middleware?
I'd like to write a very simple middleware using actix_web framework but it's so far beating me on every front.
I have a skeleton like this:
let result = actix_web::HttpServer::new(move || {
actix_web::App::new()
.wrap_fn(move |req, srv|…

Patryk
- 22,602
- 44
- 128
- 244
4
votes
1 answer
How to cache or memoize data in actix-web route?
I have an API I'm implementing where I have an expensive function that needs to be called. I'd like to either memoize this function or use a key value cache to look up previous results. I'd also consider a Mutex or similar structure, but I would…

turtle
- 7,533
- 18
- 68
- 97
4
votes
1 answer
tokio-postgres and database query
There is such a module code (for working with a database):
use tokio_postgres::{NoTls, Error};
pub async fn hello() -> Result<(), Error> {
// Connect to the database.
let (client, connection) =
…

Mikhail Krivosheev
- 569
- 3
- 18
4
votes
1 answer
the trait `std::convert::From` is not implemented for `std::io::Error`
Trying to make server with actix-web & mongodb in rust. Getting error
the trait std::convert::From is not implemented for std::io::Error
here is my code
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
use…

Niraj Gawande
- 137
- 1
- 11
4
votes
0 answers
Is it possible to send a response before fully transferring a large POST request using Actix-Multipart?
I'm looking at the actix-multipart example and there's a lot of blocking file IO. Is it possible to send a response before downloading the file? Multipart isn't Send. I want to do something like this:
async fn save_file(mut payload: Multipart) ->…

Ripread
- 330
- 2
- 10