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

How to get Cookie from Request in Actix 2.0

I want to get cookie's value from request. I found that in Actix 0.x.x, cookie's value could be get from calling fn get_cookie(req: HttpRequest) { let cookie = req.cookie("name") <-- Here return HttpResponse::Ok() .body( …
SaltyAom
  • 81
  • 2
  • 4
6
votes
3 answers

How to use routes attributes macros for multiple methods in Actix-Web

In the Actix Web Framework, how does one use the route attributes macros (#[http_method("route")]) to bind multiple http methods to one function? For example, I have this trivial endpoint: /// Returns a UUID4. #[get("/uuid")] async fn uuid_v4() ->…
mattgathu
  • 1,129
  • 1
  • 19
  • 28
6
votes
2 answers

How to use pooling of database inside function using actix?

I created a pool for MySQL database like this: let database_url = env::var("DATABASE_URL").expect("set DATABASE_URL"); let manager = ConnectionManager::::new(database_url); let pool = r2d2::Pool::builder() .build(manager) …
Cliff Anger
  • 195
  • 2
  • 11
6
votes
1 answer

What's the easiest way to get the HTML output of an actix-web endpoint handler to be rendered properly?

I've defined an endpoint with actix-web like so: #[derive(Deserialize)] struct RenderInfo { filename: String, } fn render(info: actix_web::Path) -> Result { // ... } App::new() …
spease
  • 686
  • 6
  • 15
5
votes
1 answer

'Access-Control-Allow-Origin' missing using actix-web

Stuck on this problem where I received this error everytime making POST request to my actix-web server. CORS header 'Access-Control-Allow-Origin' missing my javascript (VueJs running on localhost:3000) : let data = //some json data let xhr = new…
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
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
1 answer

Shutting down actix with more than one system running

My application is based around a library (Library-A) that uses actix and actix-web. I am adding a second library (Library-B) that runs an http server, also using actix-web. I use a separate thread and actix::system for this. On a SIGINT, only the…
zakum1
  • 895
  • 6
  • 20
5
votes
3 answers

What is the proper way to extract the body of an actix_web Response into a string?

I am attempting to use actix_web to fetch and display the contents of a web page. The HTTP request completes successfully and I can view the webpage, but I want to read the body into a String for printing. I tried let my_ip: String =…
BonsaiOak
  • 27,741
  • 7
  • 30
  • 54
4
votes
0 answers

Rust Thrift HBase server with Actix

I'm trying to build a Rust web framework using Actix that needs to query HBase backend. We have chosen to use the Thrift code generator to generate the APIs with this file. However we are having some troubles figuring out how to pass the connection…
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

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
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
1
2
3
15 16