Questions tagged [actix-web]

Actix-web is a web framework for Rust

Filter by
Sorted by
Tagged with
0 votes
0 answers
92 views

How to decode the token of a Basic Auth request

I have this code: #[get("/devices")] async fn devices(req: HttpRequest) -> Result<impl Responder, Error> { let devices_data = vec![ Device { id_device: 123, speed: 65.4,...
joegsuero's user avatar
0 votes
1 answer
54 views

The trait `Responder` is not implemented for `Vec<T>`

I am using actix_web in a learning project, and I am facing this error when trying to create a route : the trait `Responder` is not implemented for `Vec<TextAnnotation>` this is the code ...
Riadh Adrani's user avatar
-1 votes
1 answer
29 views

How to register multiple middleware in Actix web

I am trying to register multiple actix web middleware like this app.wrap(cors) .wrap( Logger, ) .app_data(dataA) .app_data(dataB) .service(...
Finlay Weber's user avatar
  • 3,151
0 votes
0 answers
15 views

How to pass data from one middleware to another middleware in ActixWeb

I can currently put data in the middleware and extract it in the request handler, using req.extensions_mut().insert::<MyData>(my_data); In the middleware, and then implement a FromRequest which ...
Finlay Weber's user avatar
  • 3,151
0 votes
1 answer
29 views

How to log internal error details from actix service

I have an actix_web service whose handlers consistently return Result<..., ServiceError>, where ServiceError is defined like this: enum ServiceError { // internal error caused by being ...
user4815162342's user avatar
0 votes
0 answers
42 views

How can one give webpage feedback on a long running task in Actix web?

I might have missed it, but I cannot find how to give feedback to the user on the webpage during a long running task in actix_web. Program is in Rust. Abstracted I have a route on "/calculate&...
martinkooij4's user avatar
0 votes
0 answers
34 views

Adding header to actix web request via Swagger

I'm currently using utoipa for my Swagger UI and actix_web_httpauth to authorize my requests. I added ("authorization" = String, Header, description = "JWT") to my Swagger params ...
Jan's user avatar
  • 153
0 votes
0 answers
83 views

Error running sqlx migrate run: "migration was previously applied but is missing in the resolved migrations"

I'm working on setting up database migrations using sqlx , actix-web , postgresql for my Rust project. I've added a new migration with the following steps, but I'm encountering an error when ...
Mr Coder's user avatar
  • 809
3 votes
0 answers
48 views

How to get the Chrome download indicator to work when serving a file through Actix_web

I have a React front-end application that has a download button on a page. When I click the download it hits my file serving URL and downloads the file to the browser's memory first and then it ...
OddlyGhost's user avatar
0 votes
0 answers
87 views

Error using sqlx query macros in Actix-web with PostgreSQL: DATABASE_URL must be set

I am building a Rust web application using actix-web and sqlx for handling database operations with PostgreSQL. I've created an endpoint to insert new subscriptions into the database using sqlx's ...
Mr Coder's user avatar
  • 809
1 vote
1 answer
97 views

Rust Actix Web with HTTPS - stream error: request parse error: invalid Header provided

I am working on a project with a simple web server using Rust actix_web. I have set up an HTTP server, running on port 4000: HttpServer::new(move || { App::new() .wrap(Logger::...
Jacob Davis's user avatar
0 votes
1 answer
39 views

HTTP response body from `Arc<[u8]>` in Actix-web?

I'm writing a web server using Actix-web. I have a cache component that stores some data as Arc<[u8]>, now I'd like to send these directly without making an unnecessary copy. I didn't find any ...
cube's user avatar
  • 3,899
2 votes
1 answer
92 views

How to effeciently Serve Large Files using Actix Web for Rust

Here is my scenario, I have written an API endpoint using actix-web and rust which is running inside a Linux VM. When the API is hit, it runs a job and creates a zip file. This zip file is around 3.5 ...
OddlyGhost's user avatar
0 votes
0 answers
82 views

Running background jobs in an Actix wep application

I have a small Rust wep application created with Actix. While running the Actix web server, I want the application to continuously run a loop in the background that runs a task every X seconds. I'm ...
Patrick Kerwood's user avatar
0 votes
0 answers
52 views

How to return mongodb Error from extjson::de::Error

I have a function, which inserts new records to the database and updates another collection. pub async fn create_post( &self, new_post: Post, user_repo: &UserRepo, ) -> Result&...
Sasha Zoria's user avatar
1 vote
1 answer
78 views

"error serializing parameter 8: cannot convert between the Rust type `alloc::string::String` and the Postgres type `_text`"

i'm using actix-web framework version 4.4 and when i'm try to insert a row to postgres database with using tokio-postgres package and this package i take this error. My columns on users table on ...
Necoo33's user avatar
  • 23
0 votes
0 answers
49 views

How to mock downstream API call using mockito

I'm attempting to use the mockito crate to mock downstream API calls. However, it doesn't seem to be functioning as anticipated. Here is my code, use actix_web::{get, App, HttpServer, Responder }; use ...
Gurunath's user avatar
  • 341
0 votes
1 answer
111 views

Rust Actix TLS error -> stream error: request parse error: invalid Header provided

I try to make a Rust Actix TLS web server. Project layout . ├── .env ├── Cargo.lock ├── Cargo.toml ├── certs │   ├── cert.pem │   └── key.pem └── src ├── api_error.rs ├── handlers.rs └── ...
Xobtah's user avatar
  • 465
0 votes
1 answer
102 views

Always getting 404 response when using service with scope in actix-web

I am writing an application using Actix Web and when configuring the routes i wanted to use scopes. The problem is that I can't seem to get them working like they should according to the documentation....
lucasfelber's user avatar
0 votes
1 answer
111 views

How to send a cookie in Actix-Web for Any version of Firefox

I am currently building a web server with authentication. The problem is that I can't setup cookie creation (despite the fact that my browser receives the information correctly). My code use actix_web:...
nalili's user avatar
  • 1
2 votes
1 answer
67 views

How to set message size limit for actix websocket actorless?

I need some help. So, I'm trying to send a websocket message that is in the size of around hundreds of kbs. I am using actix web, with actorless websockets. The problem is once, the websocket message (...
Ghiffar's user avatar
  • 45
0 votes
1 answer
39 views

How to return a Stripe checkout session in Actix Web?

I am rewriting a Stripe implementation I had in Rust and all is well except I cant figure out how to return the response properly in Actix Web. I can return details such as the redirect url or ...
bbest12g's user avatar
2 votes
2 answers
163 views

What does `actix-web` use a provided `tokio` runtime for?

The documentation for actix_web::HttpServer::run() says This method starts a number of HTTP workers in separate threads. [...] One worker set is created for each socket address to be bound. [...] ...
Dreamer's user avatar
  • 1,182
0 votes
1 answer
152 views

How to implement Server sent events in Actix?

I am trying to implement server-sent events in Rust using Actix Web. I'm just trying to stream OpenAI responses to the client. I have figured out how to handle the stream from OpenAI but I'm not sure ...
Nane's user avatar
  • 2,420
1 vote
0 answers
111 views

How to launch a (Rust)Actix-web server as a lib from another thread

I want to launch my simple actix-web server from a c++ console app as a proof of concept. This is my attempt in the Rust code: lib.rs use std::{io}; use actix_web::{get, middleware::Logger, App, ...
pSquared's user avatar
0 votes
1 answer
89 views

How to send a PDF over Axios and receive over in Actix Web

I've been trying to do this multiple ways and it doesn't seem to work. I'm using NextJS so first I call my Next API: ... mutateUser( await fetchJson("/path/to/api", { ...
Santiago Medina's user avatar
1 vote
1 answer
68 views

Expected `()`, found `Result<ServiceResponse<B>, _>` using middleware in actix_web trying to return Ok

I'm trying to accomplish a very simple task here. I don't understand why it has become so complex. I'm attempting to modify headers before they reach the service and return a failure if a certain ...
user63898's user avatar
  • 30k
0 votes
0 answers
98 views

Getting expected `HttpResponse<B>` , found `HttpResponse` in actix web middleware

i am trying to create a middleware to validate jwt token using actix web . Here is the middleware .This tends to get the Bearer token from the header and validate it and add the user struct to the ...
Biswas Sampad's user avatar
0 votes
1 answer
92 views

actix_web + tera tamplates give me [actix_web::data] Failed to extract `Data<tera::tera::Tera>` for `index` handler wrap the data with `Data::new()`

I tried to make actix-web and Tera work together, from examples I found online. This is my code: use actix_web::{get, web, Result, App, HttpServer, HttpRequest, Responder, HttpResponse}; use serde::{...
user63898's user avatar
  • 30k
-1 votes
1 answer
172 views

How to fix "cannot infer type of the type parameter E`` declared on the enum `Result`"?

I am writing an online latex editor, the user can edit the latex document in the browser. When user clicks the "compile" button, I want to push the server side latex log output to the client....
Dolphin's user avatar
  • 31.1k
0 votes
0 answers
53 views

Running actix web server on iOS

I am facing issues when trying to run web server written in Rust, on iOS / Android devices. Have tried both Actix-web and Rocket. I have followed the steps mentioned in the article: https://digvijayu....
Ishan Malviya's user avatar
0 votes
2 answers
68 views

How do I pass the std::env::vars() object into a function

What I'm trying to do: pass env vars to a function: I have a function which takes the std::env::vars() object and returns a database configuration object, like so: pub fn config(mut vars: Vars) -> ...
Eleanor Holley's user avatar
0 votes
1 answer
104 views

Actix_web server to fetch its own tls certs

I am working on a Webserver which will provide differnt endpoints using https. The Server itself is running fine, but I want to add the auto-reneval of the tls certs using let's encrypt to the server, ...
Mindxxxd's user avatar
0 votes
1 answer
45 views

How to modifie a struct without mutex? [duplicate]

It's the same thing as this question but with actix. I have multiple threads that read often, while another thread writes once a day. Don't really care whether readers get an old copy of the data or a ...
julien's user avatar
  • 110
0 votes
1 answer
84 views

why the validator did not work as expect in rust

I am using actix-web as my web server, now I want to limit the request parameter length, what I am tried to do like this: use actix_web::{get, App, HttpResponse, HttpServer, Responder, web}; use ...
Dolphin's user avatar
  • 31.1k
0 votes
1 answer
90 views

Why am I getting 404 with Rust in docker

Here's my Dockerfile: # Build stage FROM rust:slim-buster as builder RUN apt-get update && \ apt-get install -y pkg-config make g++ libssl-dev cmake libmariadb-dev-compat openssl && ...
Jan's user avatar
  • 153
-1 votes
1 answer
66 views

How to use spa from actix_web_lab? It doesn't seem to exist

error[E0432]: unresolved import `actix_web_lab::web::spa` --> backend/src/main.rs:14:5 | 14 | use actix_web_lab::web::spa; | ^^^^^^^^^^^^^^^^^^^^^^^ no `spa` in `web` For more ...
Kent Daniel's user avatar
1 vote
1 answer
127 views

How to persist data across routes using actix_session and RedisActorSessionStore

I am struggling to retrieve session data on routes after initially writing to the Redis database. When I insert into the session, i can imeediatley after view those statements with session.entries() ...
Garrett Berg's user avatar
0 votes
1 answer
42 views

Error reading a file path from struct - Rust- Actix web

i'm working with Rust and with the framework Actix-web and I'm having a little problem. I'm trying to read a file from my computer with this method: The problem is that when I execute this code, I ...
trissaik's user avatar
1 vote
0 answers
151 views

actix_web shutdown hook/handler?

I have written a small web application using actix-web. As part of starting the application I'm taking a resource and passing it in as part of the app_data for the HttpServer App. I want to clean up ...
thomasa88's user avatar
  • 630
0 votes
1 answer
101 views

Returning 204 No Content from Actix Web

I have a function, with the signature: async fn index(bearer_control: web::Json<BearerControl>) -> Result<String> { It is used an a web server: HttpServer::new(|| App::new().route(&...
fadedbee's user avatar
  • 43.1k
1 vote
2 answers
222 views

rust yew app working on local laptop/pc not behind nginx

This is prob very easy to solve(I hope) I never deployed wasm apps before and now I have a working frontend(rust yew) and backend(actix) working locally on my laptop and PC when I run it without nginx,...
rek2's user avatar
  • 111
0 votes
1 answer
154 views

actix-web error accepting connection: Too many open files (os error 24)

I am using actix-web for an HTTP server, it usually has about 200 requests per 12 seconds, After the first few requests I am continuously getting this error [2023-07-23T07:39:48Z ERROR actix_server::...
Emmanuel Thomas's user avatar
0 votes
0 answers
35 views

How to match `/foo.*` prefix in Actix?

I would like to handle these cases in Actix: /foo /foo/ /foo/.* (anything including slashes) Note that foo is a constant string, and I do not need to actually parse the path. Instead, in my handler ...
Yuri Astrakhan's user avatar
0 votes
1 answer
31 views

Implement FromIterator correctly to collect values from iter into my struct

I want to iter over my user and collect specific values based on my Query. My actix-web endpoint should return the key and collected values in my IsumisData struct. Do I need to implement FromIterator ...
Jan's user avatar
  • 153
0 votes
0 answers
43 views

AWS EC2 requests to server result in ERR_CONNECTION_TIMED_OUT from anywhere but localhost

I have created an EC2 instance and started a server there. The server is up and running as a service with systemd. However, accesing the server anywhere but on localhost results in a time out. When ...
schneedy's user avatar
1 vote
0 answers
176 views

How to properly validate actix web headers (rust)?

I am fairly new to rust so trying to find the proper way to handle this specific use case. We are using actix web server and have created a route which maps to the following function: #[derive(serde::...
o.bannister's user avatar
0 votes
0 answers
55 views

How do I implement proper threading mechanism in rust to handle 2 async call at once from one main funciton

All I am pretty new to Rust and I am still learning. Please pardon me if I say something wrong. I am creating a very simple web application using Rust, The frameworks I am using are actix_web, and ...
OddlyGhost's user avatar
0 votes
0 answers
40 views

arm_neon.h:9193:17: error: expected declaration specifiers or '...' before 'uint32_t' when build rust docker image in mac book M1 chip

When I tried to build a simple actix-web hello world rust application in mac book pro with M1 pro chip, shows error like this: #10 26.01 cargo:warning=15826 | vld1_dup_s8 (const int8_t* __a) #10 26....
Dolphin's user avatar
  • 31.1k
0 votes
2 answers
257 views

401: Not Authorized error only when requesting data using fetch

I was trying to get response from an API running on localhost, I had gotten a generated bearer token from the login endpoint and now I just wanted to use the token to get the user claims on it. My ...
RikSantra's user avatar

1
2 3 4 5
10