Questions tagged [actix-web]
488 questions
2
votes
1 answer
How to efficiently use Actix Multipart to upload a single file to disk?
TL;DR:
I have issues getting my head around Actix Multipart when iterating over "data chunks" and saving them to a single file; all while not messing up Rusts error handling, efficient memory management and async processing.
Details and…

Frederic Laing
- 41
- 3
2
votes
1 answer
Running an actix web server on a separate thread
I'm new to actix, and I'm trying to understand how I can run a server on one thread and send requests from another.
This is the code I have so far
use actix_web::{web, App, HttpResponse, HttpServer};
use std::{sync::mpsc::channel,…

14159
- 125
- 5
2
votes
1 answer
Rust Actix-Web sqlx optional feature `time` required for type TIMESTAMPTZ of column #4 ("created_at")
I'm creating my model using Actix-Web framework and sqlx library to make all sql queries with postgresql.
My problem is that I'm creating my model and when I query to get all the rows from a table, it gives me an error in the 'created_at'…

arturfil
- 380
- 5
- 13
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…

blurt.washday
- 21
- 2
2
votes
2 answers
Serialize data into struct model, where two of those fields' data are calculated based upon other fields in the struct
I have a model here:
#[derive(Debug, Serialize, Deserialize)]
pub struct ArticleModel {
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
pub id: Option,
pub text: String,
pub author:…

Matthew Trent
- 2,611
- 1
- 17
- 30
2
votes
1 answer
How to read HttpRequest body
I'm trying to implement a simple Actix API, and the first method I'm testing, is one for creating a "book" object in a SQLite database. I've got the up.sql, schema, model and DAO (just for encapsulating the DB code) all writen, but I'm lacking a…

Zerok
- 1,323
- 1
- 24
- 56
2
votes
2 answers
Share state between actix-web server and async closure
I want to periodically fetch data (using asynchronous reqwest), which is then served at an http endpoint using actix-web as a server.
(I have a data source that has a fixed format, that I want to have read by a service that require a different…

Kjell Andreassen
- 753
- 6
- 10
2
votes
1 answer
What does this # line of code mean in Rust?
Im learning rust and I came across this sample code:
use actix_web::{middleware, web, App, HttpRequest, HttpServer};
async fn index(req: HttpRequest) -> &'static str {
println!("REQ: {req:?}");
"Hello world!"
}
#[actix_web::main]
async fn…

Joona Ritva
- 143
- 4
- 15
2
votes
1 answer
How do you create an actix-web HttpServer with session-based authentication?
I'm working on an internal API with which approved users can read from and insert into a database. My intention is for this program to run on our local network, and for multiple users or applications to be able to access it.
In its current state it…

piccoloser
- 181
- 1
- 10
2
votes
0 answers
How to change request in actix-web route acting as a simple reverse proxy returning the response?
I need to add to my actix-web instance a route that acts as a simple reverse proxy according to these criteria:
I get a call for GET https://host_1:8000/some_route (please don't mind the HTTPS, I'm not handling SSL in my code)
the reverse proxy…

Fred Hors
- 3,258
- 3
- 25
- 71
2
votes
0 answers
What is the proper way of serving web files (html+js+wasm) using Actix-Web?
I'm trying to serve my web files (html+js+wasm) generated with trunk build from my server using Actix-Web by responding with
HttpResponse::Ok()
.content_type(ContentType::html())
.body(include_str!(r"..\..\frontend\dist\index.html"))
The…

Lodea
- 119
- 12
2
votes
1 answer
Cross-domain cookie is lost at refresh
My API (Actix-web Rust) is hosted on render.com and my frontend (Vue 3 app) on vercel.com. When I log in, my API send a cookie with SameSite=None, Secure=true and domain render.com. But when I refresh or leave the page, the cookie is lost.
Is it a…

Ershetz
- 35
- 4
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
actix-web: How to create a route like this: /starts-with/a/b/c/d/.../e?
#[get("/starts-with/{other_url}")]
async fn t1(other_url: web::Path) -> impl Responder {
other_url.to_string()
}
This handler works for /starts-with/a, but it doesn't work for /starts-with/a/b.
How can I create a route which works with…

Max Block
- 1,134
- 3
- 16
- 23
2
votes
1 answer
actix web lifetime in web::Data
I am trying to work with Data in acitx web, but it wont work with a defined lifetime. Why am i getting this error and how do i fix it? implicit elided lifetime not allowed here assuming a 'static lifetime
#[get("/search/{query}/")]
async fn…

frederick
- 25
- 3