Questions tagged [actix-web]
488 questions
0
votes
1 answer
Actix web actors are being created more than once
I am just playing a bit with Actix web and Actix actors, while I was building a simple app which gives out milliseconds I observed that Actix is creating more than one actor. I want to restrict it to only one, but I am unable to do it.
What's the…

manu
- 223
- 1
- 2
- 12
0
votes
1 answer
Spawn reading data from multipart in actix-web
I tried the example of actix-multipart with actix-web v3.3.2 and actix-multipart v0.3.0.
For a minimal example,
use actix_multipart::Multipart;
use actix_web::{post, web, App, HttpResponse, HttpServer};
use futures::{StreamExt,…

naughie
- 315
- 2
- 14
0
votes
1 answer
Pre-generating a "queue" of heavy data to get it immediately in actix-web endpoint
I use actix-web and want to generate pairs of (password, password hash).
It takes some time (0.5s).
Instead of generating each pair on demand:
pub async fn signup (data: web::Data) -> impl Responder {
// Generate password
let…

Sergey
- 19,487
- 13
- 44
- 68
0
votes
1 answer
How do I pass multipart/form-data stream from client to third-party server, using Actix client?
I'm creating my own frontend client to upload videos to a video hosting service.
According to the API docs, I am to POST a multipart/form:
curl -X POST \
-H "Key: YOUR_KEY" \
-F "file=@hello_world.mp4" \
…

Hunter Lester
- 2,972
- 3
- 15
- 19
0
votes
0 answers
Rust diesel aggregation query
I have some problems with performing a query using Diesel library.
I have table:
create table tasks
(
id serial not null
constraint tasks_pkey
primary key,
name …

nocl1p
- 111
- 7
0
votes
1 answer
How to use diesel's filter methods?
I have a little actix web project. There is a such model:
#[derive(Serialize, Deserialize, Insertable, Identifiable, Queryable, PartialEq, Debug)]
#[table_name = "confirmations"]
pub struct Confirmation {
pub id: Uuid,
pub email: String,
…

nocl1p
- 111
- 7
0
votes
1 answer
Compilation problem with Actix TCP client implementation
I'm very new to Rust and willing to make some Linux service for Orange Pi Zero in Actix-web, that will act as a "gateway" to other network device (some dumb Chinese network relay with 4 inputs and 4 ouputs which is controlled by AT commands via TCP…

Skyggedans
- 25
- 5
0
votes
1 answer
The trait Serialize is not implemented despite being implemented?
I'm using actix-web for creating an app for reclaiming packets, then inserting them into MongoDB database. I have a struct
#[derive(Serialize, Deserialize, Debug)]
pub struct Gyro{
/// GYRO FRONT + MIDDLE
pub x0x800: [i32; 12],
…

Patrox27
- 3
- 2
0
votes
1 answer
I can't capture the DB reference
I'm trying to create an API using Actix-web, async-grahpql and sqlx with postgresql
In the QueryRoot of the async-graphql I am trying to capture the reference of the DB and make the query the database with sqlx, but it gives me an error
let items =…

BeGo
- 155
- 8
0
votes
1 answer
How can I pass multiple values of the same type with App::data() in actix-web?
The official example code:
/// use std::cell::Cell;
/// use actix_web::{web, App, HttpResponse, Responder};
///
/// struct MyData {
/// counter: Cell,
/// }
///
/// async fn index(data: web::Data) -> impl Responder {
/// …

Anunaki
- 763
- 2
- 8
- 18
0
votes
0 answers
rust actix: how can I properly return an App instance from a module?
I'd like to return an App instance from a module, but I just don't get anywhere.
I am propably doing everything wrong, that can be done wrong.
Here's my effort so far:
app.rs (called by main.rs)
extern crate actix_web;
extern crate actix_http; // =>…

LongHike
- 4,016
- 4
- 37
- 76
0
votes
1 answer
actix web with mongodb project fails to build after an async call to mongodb is added
I'm implementing a REST API using actix-web and mongodb for the data back-end. I am using version 1.1.1 of the official rust-mongodb driver from crates.io and Rust 1.46.
If I add code to make a call to the mongodb collection to get records for…

Nikos Steiakakis
- 5,605
- 7
- 44
- 54
0
votes
1 answer
Rust actix_web::main "expected `std::result::Result<(), std::io::Error>` because of return type" but suggested type doesen't work
I'm new to rust and started experimenting with actix_web and sqlx. the goal is to create a simple, open-source Blog engine, but after I implemented the CLI argument parser and basic SQL connection pool, the code doesn't compile anymore. I'm getting…

LeMoonStar
- 103
- 1
- 9
0
votes
0 answers
Actix-web loosely typed JSON to strongly typed structure
I have a case when I need to perform some type conversions on incoming JSON. Different clients send pretty much the same data in different types:
{"amount": 49.90}
{"amount": "49.90"}
My struct & handler:
struct Amount {
pub amount: f64,
}
pub…

Alex Smith
- 311
- 1
- 3
- 14
0
votes
1 answer
How do you get the json from an use actix_web::HttpRequest into struct?
What is the simplest way to get json from the HttpRequest into a struct you created. Here is the main.rs
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
…

Apothan
- 187
- 1
- 2
- 9