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
28
votes
4 answers

How can I parse query strings in actix-web?

How can I parse the name and color arguments from the following URL using actix-web? http://example.com/path/to/page?name=ferret&color=purple I suppose my path should be /path/to/page and then when I try to query for name I receive an empty string…
H. Desane
  • 593
  • 1
  • 8
  • 16
18
votes
2 answers

How do I configure actix-web to accept CORS requests from any origin?

I am building a REST API with actix-web. How do I configure CORS to accept requests from any origin? Cors::new() // <- Construct CORS middleware builder .allowed_origin("localhost:8081") .allowed_methods(vec!["GET", "POST"]) …
Bopsi
  • 2,090
  • 5
  • 36
  • 58
16
votes
2 answers

Is there simpler method to get the string value of an Actix-Web HTTP header?

Is this is the only possibility to get the content-type header from an Actix-Web request? This has to check if the header is available or if to_str failed... let req: actix_web::HttpRequest; let content_type: &str = req .request() …
Markus
  • 512
  • 1
  • 4
  • 21
15
votes
2 answers

Why do I get "System is not running" error after upgrading actix-rt to 2.0.2?

I attempted to update to actix_rt 2.0.2 and have since been getting the following error: thread 'main' panicked at 'System is not running' Here is my minimal example: # Cargo.toml [dependencies] actix = "0.10" actix-web = { version = "3.3.2",…
Marcus Ruddick
  • 9,795
  • 7
  • 28
  • 43
13
votes
1 answer

How to pass many params to rust actix_web route

Is possible to pass more than one parameter into axtic_web route ? // srv.rs (frag.) HttpServer::new(|| { App::new() .route( "/api/ext/{name}/set/config/{id}", web::get().to(api::router::setExtConfig), ) }) .start(); //…
Piotr Płaczek
  • 530
  • 1
  • 8
  • 20
12
votes
2 answers

How to run a callback function on actix-web server start?

Currently my main function, where the server starts looks like this #[actix_rt::main] async fn main() -> std::io::Result<()> { let address = "0.0.0.0:3000"; HttpServer::new(move || { let app_state = {...some state}; …
high incompetance
  • 2,500
  • 4
  • 18
  • 26
12
votes
2 answers

How to return an early response from an actix-web middleware?

My clients authorize through a token in the Authorization header which needs to be checked for each request. If this header is missing or I cannot find a corresponding user, I want to return the HTTP code Unauthorized, else I want to handle the…
ThinkPat
  • 133
  • 1
  • 9
11
votes
4 answers

How to get the body of a Response in actix_web unit test?

I'm building a web API service with Rust and actix_web. I want to test a route and check if the received response body is what I expect. But I'm struggling with converting the received body ResponseBody into JSON or BSON. The called route…
zel873ju
  • 139
  • 2
  • 7
11
votes
1 answer

Does the Rust actors framework Actix guarantee message order between two actors?

In the case of one single actor sending a message to another single actor. I couldn't find anything about this in the official documentation.
Gustavo Basso
  • 129
  • 11
10
votes
1 answer

Rust actix::web logging all requests

Is there a way to log all requests being received by actix-web irrespective of whether the endpoint exists or not? It seems I need to use middleware for this, is this the recommended approach?
Allan K
  • 379
  • 2
  • 13
10
votes
2 answers

Rust actix_web inside docker isn't attainable, why?

I'm trying to make a docker container of my rust programme, let's look Dockerfile FROM debian RUN apt-get update && \ apt-get -y upgrade && \ apt-get -y install git curl g++ build-essential RUN curl https://sh.rustup.rs -sSf | bash -s --…
unegare
  • 2,197
  • 1
  • 11
  • 25
8
votes
3 answers

Rust actix-web: the trait `Handler<_, _>` is not implemented

I've moved from using actix-web 3.x.x to 4.x.x. and the code that's been running perfectly fine before is now throwing this error: the trait bound `fn(actix_web::web::Query, actix_web::web::Data>) -> impl…
ilmoi
  • 1,994
  • 2
  • 21
  • 45
7
votes
1 answer

How can I pass structs from an Actix middleware to the handler?

I'm trying to write an authentication middleware for my Actix application. When validating the request in the middleware, I make a call to a database to retrieve the necessary user data to validate the incoming request. Once the request has been…
Rob123
  • 895
  • 6
  • 10
7
votes
1 answer

Run multiple actix app on different ports

I am trying to run two app (one to admin on port 3006 and another to serve data on port 8080). They shared database pool, cache... For actix 1.0 i had this working (i don't know if it's the best way to do that) : let server = Server::build() //…
Etienne Prothon
  • 982
  • 10
  • 30
7
votes
5 answers

Actix-Web reports "App data is not configured" when processing a file upload

I'm using the Actix framework to create a simple server and I've implemented a file upload using a simple HTML frontend. use actix_web::web::Data; use actix_web::{middleware, web, App, HttpResponse, HttpServer}; use std::cell::Cell; // file upload…
Samuel Dressel
  • 1,181
  • 2
  • 13
  • 27
1
2 3
15 16