Questions tagged [actix-web]
488 questions
0
votes
1 answer
CSS file is not read properly using actix-web and maud
CSS is not working via link rel attributes of maud with actix-web. Where I've made mistake(s)?
I think that position where I wrote link rel attributes is correct.
main.rs
use actix_files as fs;
use actix_web::{get, App, HttpServer, Result as…

electrical apprentice
- 115
- 5
0
votes
1 answer
What is the type for a vector of async functions that return "impl Responder"?
use actix_web::{delete, get, post, put, HttpResponse, Responder};
#[get("/user")]
async fn get_user() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
}
#[post("/user")]
async fn add_user() -> impl Responder {
…

Metal_Maks_Shape
- 49
- 4
0
votes
0 answers
How to drop connection to client from a handler or middleware
I am writing some anti DoS / brute force actix web middleware from which I would like to block some badly behaving clients. The blocking should be implemented by simply closing the client socket without sending any status or response to it. I found…

kyku
- 5,892
- 4
- 43
- 51
0
votes
1 answer
How can I restart my actix httpserver at runtime in rust?
I wanted to start my web service at runtime, so I wrote the following code. However, the first startup succeeded, and the second startup always failed. I suspect that resources are occupied after the first shutdown of the web service. Who can tell…

ljhiiii
- 1
- 1
0
votes
1 answer
Unable to connect with Client due to Connect(Timeout) Error
I'm trying to make an https request to a third party API from my Actix Web Server. I'm using awc::Client to make the request. I'm running the server on Windows 10 with the openssl features enabled in the Cargo.toml file.
Here is the code that is…

Samuel Labrador
- 15
- 2
0
votes
0 answers
Executing Python Async functions in Actix web sockets
I am trying to execute a python async function in an actix web socket.
I was able to figure out how to execute a sync function and send the response back to the web socket. However, I am unable to do the same with the async functions.
Here is my…

Sanskar Jethi
- 544
- 5
- 17
0
votes
4 answers
Actix web send image as Response
I want to send image to the Frontend with a path /images/{pic_name}.
Here is the actix web way
.service(web::resource("/images/{pic_name}").route(web::get().to(images)))
And here the fuction images:
async fn images(req: HttpRequest, info:…

Klod Lala
- 153
- 8
0
votes
1 answer
actix-web app_data is always None in request handler
I want to register application level data when configuring Actix http server, but when I try to access the data in a request handler with HttpRequest::app_data() I always get None. The code below panics in the index request handler at the expect…

Markus
- 2,412
- 29
- 28
0
votes
1 answer
expected struct `rustls::client::ClientConfig`, found struct `ClientConfig`
I am getting this error when I try using this function https://docs.rs/awc/2.0.3/awc/struct.Connector.html#method.rustls
async fn get_client_config() -> rustls::client::ClientConfig {
let root_certs = rustls::RootCertStore::empty();
…

GrvTyagi
- 4,231
- 1
- 33
- 40
0
votes
0 answers
Propagate different errors when the function output is fixed by a macro
I'm new to rust, and facing an error when propagating different error types (from actix and sqlx in this case).
I saw that similar problems are addressed by changing the return of the function to the appropriate type, or to an enum of the different…

Marc Garcia
- 3,287
- 2
- 28
- 37
0
votes
1 answer
Write behind async tasks
In a web environment with Actix-Web I want to write behind data to a database, async so the request is not held up. This could also be calling a webhook or calling an API to send an email.
With Scala I would create a queue and use a thread pool…

KingOfCoders
- 2,253
- 2
- 23
- 34
0
votes
1 answer
How can I implement REST API using paperclip in Rust so that the response types are presented in the swagger ui
Background
I am using the actix-web crate to implement a REST API and the paperclip crate to generate a swagger spec endpoint.
The Problem
In the swagger ui, the response type is shown as application/json, but the model of the response is not shown.…

David Sackstein
- 500
- 1
- 5
- 19
0
votes
0 answers
How to handle provider-like objects in Actix-Web
I have a validate endpoint, which takes in a JWT that's POSTed to it, and that works fine. Currently set up like this in the application setup:
let server = HttpServer::new(|| {
App::new()
.wrap(Logger::default())
…

dantdj
- 1,237
- 3
- 19
- 40
0
votes
1 answer
How can I get the response status in actix-web middleware?
I am using actix-web 3. I would like to access the current status code from within Actix-web’s middleware system.
I would like to modify the request based on the StatusCode, is this possible?
For instance if the user sends some data that causes…

Allan K
- 379
- 2
- 13
0
votes
1 answer
Clone reqwest response
I'm currently trying to test an API endpoint using actix-web and reqwest.
I can insert some records (using sqlx), and then make the request and check it returned a 200 HTTP status, and corroborate that the returned data belongs to the user created -…

Johann Esburgo
- 41
- 1
- 6