Questions tagged [rust-actix]

Actix is a rust library built on the Actor Model which allows applications to be written as a group of independently executing but cooperating "Actors" which communicate via messages.

Actix (source code) is a Rust actors framework.

233 questions
2
votes
1 answer

How to display custom Tera errors in Actix?

I'm studying rust/actix/tera and cannot figure out how may I return a custom tera error string in the actix output. Here's my code: use actix_web::{App, get, error, Error, HttpResponse, HttpServer}; use tera::{Tera, Context}; use…
NarūnasK
  • 4,564
  • 8
  • 50
  • 76
2
votes
2 answers

Multi-threading in async rust - why is my code failing to parallelize?

I'm trying to intentionally exhaust an API limit (900 calls) by running the following function: #[get("/exhaust")] pub async fn exhaust(_pool: web::Data, config: web::Data>) -> impl Responder { let mut handles = vec![]; …
ilmoi
  • 1,994
  • 2
  • 21
  • 45
2
votes
1 answer

How to set the status code of a response?

I'm using actix for a web application I'm working on, and I'm trying to set the status code 409 to a response, but I don't know how to do that. Something a bit like this: HttpResponse::StatusCode(409).json(Status{ value: val, …
Attilah
  • 17,632
  • 38
  • 139
  • 202
2
votes
1 answer

Get the app state in FromRequest implementation

I have an actix web server and I want to get the state of my server within a FromRequest implementation. I'd tried something like: impl FromRequest for User { type Config = (); type Error = Error; type Future = Pin
2
votes
1 answer

ensure actix logging in chronological order // pre-process

I have actix-web and struggle debugging, as the logger writes at the end only, and if something fails, it doesnt write at all. RUST_LOG=actix_web=debug,actix_server=debug let server = HttpServer::new(move || { App::new() …
til
  • 832
  • 11
  • 27
2
votes
3 answers

Serving static files with actix-web 2.0

I'm struggling with actix-web 2.0 framework of rust. I want my rust server to serve the my index.html file but most of the help available is of older versions and hence a lot has changed in newer version. I tried following code but it's not working…
Fatima Nasim
  • 31
  • 1
  • 8
2
votes
0 answers

Sending the same message to other actors, without clone in Actix/Rust

I need to send the same message object to other actors. It will be very costly to clone it each time. And it shouldn't actually be necessary. And I get the error as expected. "value moved here, in previous iteration of loop". Passing parameters with…
Mesut
  • 21
  • 3
2
votes
0 answers

actix-web how to send response data stream by decompressing zip file

How to implement actix-web response to send file data stream, I want to send it to http response body by decompressing zip file use zip; use std::fs::File; use std::io::prelude::*; use encoding_rs::Encoder; use std::str; use actix_web::{web, App,…
ProJin
  • 101
  • 3
  • 9
2
votes
1 answer

Actix PayloadConfig limit not respected

I've got problem with setting the payload limit in Actix. No matter how I try to configure it (with app_data, data, on service level etc) I always get 413 http response with body A payload reached size limit. and following log: Error in response:…
ZZ 5
  • 1,744
  • 26
  • 41
2
votes
1 answer

How to await a Rust Future on a non-async function

Rust newbie here (<7 days into learning), the second hurdle I am trying to overcome after ownership rule is async/await. I am writing a test that calls an async function and I need to get the result from the Future without using the keyword await. I…
undefined
  • 2,939
  • 4
  • 23
  • 35
2
votes
3 answers

Do a synchronous http client fetch within an actix thread

I have an actix endpoint, and I need to do a synchronous http client fetch to get some results, and return some data. My endpoints cannot use async, so I can't use any .await methods. I've tried using reqwests blocking client in my endpoint like…
dessalines
  • 6,352
  • 5
  • 42
  • 59
2
votes
0 answers

Can I use actix_web on AWS Lambda without spawning a thread for HttpServer?

I am building a REST API using AWS Lambda and Rust. I want the Rust code to handle multiple resources from within the same library as this seems to make more sense than creating a separate binary for every resource. What I would like to do is use…
rinde
  • 1,181
  • 1
  • 8
  • 20
2
votes
1 answer

How to use MongoDB with r2d2 and actix in rust

I am trying to make a basic web application with the rust language, using the actix framework and r2d2 with mongodb as the database. I could not find any complete and working documentation on how to archive this. Maybe someone can help me out…
ToBe
  • 2,667
  • 1
  • 18
  • 30
2
votes
1 answer

How can I share sessions between actix-session and a PHP application when using Redis as session storage?

I want to switch my PHP website using Redis as session storage to actix-web. The only problem I've encountered is sharing sessions between my subdomains. I have many services and only some of them will get switched to Rust. A crate already exists…
Cliff Anger
  • 195
  • 2
  • 11
2
votes
1 answer

Need IP address as string for rate limiting - Rust Actix

I'm trying to implement a rate-limiter based on IP address, in a websocket application, but I can't figure out how to get the IP address as a string. I've been scouring the docs and there's no mention of IP address. I have a addr:…
dessalines
  • 6,352
  • 5
  • 42
  • 59