Questions tagged [actix-web]

488 questions
-1
votes
1 answer

how to case async fn as future

async fn get_current_user( req: HttpRequest, payload: &mut Payload, config: &CurrentUserConfig, ) -> Result { todo!() } #[derive(Debug)] pub struct CurrentUser(User); impl FromRequest for CurrentUser { type…
mxp-xc
  • 456
  • 2
  • 6
-1
votes
1 answer

is there any way to reuse the same struct or do i need to build a new one in Rust?

I got this table in postgres create table tasks_users( id serial primary key, user_id smallint, task_id integer, created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, deleted_at TIMESTAMP WITH TIME ZONE ) With this table_name |…
Dilakv
  • 83
  • 9
-1
votes
1 answer

could not find `options` in `mongodb` Rust Lang

I am trying to connect to mongodb using in rust using mongodb library here is the code use actix_web::{App, HttpServer}; use mongodb::{Client, options::ClientOptions}; #[actix_rt::main] async fn main() -> std::io::Result<()> { // Parse a connection…
Niraj Gawande
  • 137
  • 1
  • 11
-1
votes
1 answer

Borrowed value does not live long enough, moved due to use in closure E0597

I am taking my first steps on Actix-Web. But this closure causes me errors #[derive(Deserialize, Serialize, Debug, Copy, Clone)] pub struct PaginationQuery { pub limit: Option, pub offset: Option, } pub fn get_all_trainings_2( …
BoudBoud
  • 1
  • 1
-2
votes
1 answer

React and Actix: Error No 'Access-Control-Allow-Origin' header is present on the requested resource

From react i call an actix api async function richiesteFn() { try { const response = await fetch('https://exampleip/richieste', { method: 'GET', headers: { Authorization: sessionStorage.getItem('auth0_token'), }, …
GranBoh
  • 67
  • 8
-2
votes
1 answer

How to create an archive (tar, 7z, zip) on the fly?

I have an actix-web server and want to have an endpoint where user can download a dynamically generated archive (tar or zip or 7z). How can I do that? All the examples I saw either generated archive in memory (not an option, can be big) or generated…
Sergey
  • 19,487
  • 13
  • 44
  • 68
-2
votes
1 answer

How do I access the app_data in actix_web's Guard::check() function?

I am trying to implement a custom guard that checks if the authorization token is valid: impl Guard for AuthGuard { fn check(&self, ctx: &GuardContext<'_>) -> bool { // check header value here // and retrieve connection pool from…
ferd tomale
  • 845
  • 7
  • 20
-2
votes
1 answer

RUST find value in web::Data>

my "main" file mod router; mod student; use std::sync::Arc; use crate::router::init_router; use crate::router::Memory; use actix_web::{App, HttpServer}; #[actix_web::main] async fn main() -> std::io::Result<()> { dotenv::dotenv().ok(); …
Daniel
  • 181
  • 4
  • 13
1 2 3
32
33