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
3
votes
1 answer

Rust actix-web thread unsafe movement

I'm trying to write an HTTP endpoint using actix-web 1.0. I've reduced the function so that it's just returning the user that is passed to it, but the compiler still gives an error. extern crate actix_web; extern crate chrono; extern crate…
CallMeNorm
  • 2,299
  • 1
  • 16
  • 23
3
votes
1 answer

How do I prevent a timeout problem while streaming large files with an actix-web proxy?

I would like to use actix-web as a simple proxy server, but when I'm using huge files in streaming mode, the server has a timeout error and only a small part of the file will be downloaded. I'm really confused because this is a sample code from the…
David Tex
  • 87
  • 6
3
votes
1 answer

How can I print an error's message in Actix-Web without panicking?

I'm trying to understand the error handling from one of the examples from the Actix repo. It uses the failure crate to handle errors. Here's a relevant piece of code: #[derive(Fail, Debug)] pub enum ServiceError { #[fail(display = "Internal…
James Larkin
  • 541
  • 5
  • 18
3
votes
1 answer

Forward request body to response in Actix-Web

I would like to forward the Actix-Web request body to the response body (something like echo) but it gives a mismatched types error. use actix_web::*; use futures::future::ok; use futures::Future; fn show_request( request:…
David Tex
  • 87
  • 6
3
votes
2 answers

Specifying associated type in trait that inherits from another trait

I started working on my first more ambitious Rust project, and struggle with something I did not come across in any of the resources and tutorials I used for learning. The title of the question captures the abstract problem, but for the examples…
jdno
  • 4,104
  • 1
  • 22
  • 27
3
votes
1 answer

Is there a good way to implement an authentication / authorization check at the Actix route level?

My API routes are collected into a scope like so: .scope("/api", |s| s .nested("/doorlock", routes::doorlock) .resource("/config{path:.*}", |r| { r.get().with(routes::config::read); …
Ákos Vandra-Meyer
  • 1,890
  • 1
  • 23
  • 40
3
votes
1 answer

How do I access HttpRequest data inside a Future in Actix-web?

I'd like to have an Actix Web handler which responds to a POST request by printing the POST body to the console and constructing an HTTP response that contains the current URL from the request object. When reading the request's POST body, futures…
Mala
  • 14,178
  • 25
  • 88
  • 119
2
votes
0 answers

Only one package in the dependency graph may specify the same links value

I have two dependencies, actix-web and sled. Both rely on zstd, however they rely on zstd-sys v2.0.4 and zstd-sys 1.6.1 respectively. Is there a way I can "link" actix-web to one version of zstd, and sled to another? I attempted to import both…
2
votes
1 answer

Can't start a transaction on a connection in Rust Actix using MySql

I have created an wrapper, DatabaseMiddlewareFactory, that wraps a service endpoint in a connection. That connection may have a transaction started on it or it may not. I've done this for Postgresql with no problem. The wrapper does this; Get a…
Ezward
  • 17,327
  • 6
  • 24
  • 32
2
votes
1 answer

Status Codes and Headers not working in actix web

I am trying to return a response via the HTTPResponseBuilder but even when I am using a custom status_code say 307 and a header of Location: google.com, my browser is not redirecting me to the same website. Here is the sample code that I using: …
Sanskar Jethi
  • 544
  • 5
  • 17
2
votes
0 answers

How do I set trusted Sectigo SSL on a Actix server in RUST?

Based on my code using a .pem SSL certificate and key, I would like to know how I can use a Sectigo SSL that has Root CA Certificate - AAACertificateServices.crt, Intermediate CA Certificate - USERTrustRSAAAACA.crt, Intermediate CA Certificate -…
Mathe Eliel
  • 658
  • 2
  • 6
  • 16
2
votes
1 answer

web::block() fails with "`NonNull` cannot be shared between threads safely"

#[macro_use] extern crate diesel; use diesel::result::Error; use actix_web::web; use diesel::{PgConnection, QueryDsl, RunQueryDsl}; use r2d2::{Pool, PooledConnection}; use r2d2_diesel::ConnectionManager; use schema::tests::dsl::*; pub mod…
porton
  • 5,214
  • 11
  • 47
  • 95
2
votes
1 answer

How to efficiently serve a file with actix-web

In actix-web, it is possible to serve a file by returning in a handler: HttpResponse::Ok().streaming(file) But here, file must implement the Stream> trait. The File type from the crate async_std does not implement it, so I…
uben
  • 1,221
  • 2
  • 11
  • 20
2
votes
1 answer

How to implement Actix-web middleware in the latest version (3.3.2)?

I've been trying to compile the SayHi middleware from the example listed in Actix-web's documentation: https://actix.rs/docs/middleware/. The problem is that in the latest version of Actix-web (3.3.2) and Rust (1.55) this code does not compile, the…
Matt
  • 699
  • 5
  • 15
2
votes
1 answer

How to convert tera::Error to actix_web::Error?

I'm studying rust/actix/tera and cannot figure out how to implement ResponseError trait on the tera::Error, or alternatively how to convert tera::Error to actix_web::Error. With the following code snippet: match TEMPLATES.render("index.html", &ctx)…
NarūnasK
  • 4,564
  • 8
  • 50
  • 76