by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 10:39
    fakeshadow commented #1622
  • 10:39
    fakeshadow commented #1622
  • Aug 02 07:59
    omid commented #1500
  • Aug 02 04:05
    dessalines commented #1623
  • Aug 02 04:03
    JohnTitor closed #1623
  • Aug 02 04:03
    JohnTitor commented #1623
  • Aug 02 02:51
    vpzomtrrfrt commented #1623
  • Aug 02 02:39
    dessalines commented #1623
  • Aug 02 02:24
    iav opened #1623
  • Aug 01 02:48
    ctopher7 commented #645
  • Aug 01 02:38
    ctopher7 commented #645
  • Jul 29 19:42
    ajsyp opened #1622
  • Jul 28 04:23
    ndelvalle commented #855
  • Jul 25 09:35
    JohnTitor review_requested #1621
  • Jul 25 09:35
    JohnTitor review_requested #1621
  • Jul 24 11:42
    Nutomic commented #1561
  • Jul 24 01:39
    robjtede commented #1561
  • Jul 23 23:37
    Nutomic commented #1561
  • Jul 23 23:34
    Nutomic commented #1561
  • Jul 23 22:17
    codecov-commenter commented #1621
vietlib
@vietlib
can i find someone using actix with mongodb ?
Austin Tran
@tranhoangvuit

Hi guys, can some one help me take a look on this one? I want to have a class for init_routes for the whole bounded context that means I can use it own method and republic from sub folder like this:

// src/iam/mods.rs
use actix_web::web;

mod group;
mod organization;

pub use group::init_routes;
pub use organization::init_routes; // got error here: `init_routes` redefined here

pub fn init_routes(cfg: &mut web::ServiceConfig) {
  cfg.service(delete_organizations);
}

Thi is my sub folders is mods.rs and routes.rs

// src/iam/organization/routes.rs

pub fn init_routes(cfg: &mut web::ServiceConfig) {
  cfg.service(find_all);
  cfg.service(find);
  cfg.service(create);
  cfg.service(update);
}

// src/iam/organization/mods.rs
mod model;
mod routes;

pub use model::{Organization, OrganizationParameter};
pub use routes::init_routes;

Thank you so much.

David Laban
@alsuren

Hello all. I have just published my first cargo plugin: https://crates.io/crates/cargo-ngrok - it takes the 404 and 500 errors from your actix server (via ngrok) and generates handler functions and regression tests for you.

It is currently super-alpha quality (only deals with GET requests, assumes that all of your routes and tests live in src/main.rs, etc.). I would really like to hear people's first impressions about the project, so that I can drive it in the right direction.

If you have time (anyone) I would love for people to read blurb on crates.io and tell me what you think.

1 reply
Ashley Lake
@lake-effect
I'm trying to understand how to write DRY request functions with actix and struggling:
async fn req_fn(foo: &str) -> Result<ClientResponse,Error> {
    let mut client = Client::default();

    // Create request builder and send request
    client.get("http://www.rust-lang.org")
        .header("User-Agent", "Actix-web")
        .send().await
}
This doesn't work because the type is still pinned, boxed, and wrapped in Decompress:
^ expected struct `std::pin::Pin`, found struct `actix_web::dev::Decompress`
   |
   = note: expected enum `std::result::Result<awc::response::ClientResponse<std::pin::Pin<std::boxed::Box<(dyn futures_core::stream::Stream<Item = std::result::Result<actix_web::web::Bytes, actix_web::error::PayloadError>> + 'static)>>>, actix_web::Error>`
              found enum `std::result::Result<awc::response::ClientResponse<actix_web::dev::Decompress<actix_web::dev::Payload<std::pin::Pin<std::boxed::Box<dyn futures_core::stream::Stream<Item = std::result::Result<actix_web::web::Bytes, actix_web::error::PayloadError>>>>>>>, actix_web::client::SendRequestError>
How should I really be decomposing this?
matrixbot
@matrixbot
dominic_ cann I have a file as an httpresponse ?
dominic_ like a quick file download
pigbrain
@pigbrain
Hello
biot023
@biot023
Hello -- can anyone advise me on how to access my app's context from a middleware? I want to check a header exists and set something in the context if it does. I'll settle for being able to set a header in the request (not the response), though.
biot023
@biot023
Actually, that wouldn't work, would it? I'd need a separate context for each request which isn't how contexts work. Damn.
I guess my question is: can I write to the request from the middleware? Or is there something like a per-request-config that I can write to?
Michał Hanusek
@hanusek
Hello. I have a problem. Please help me.
error[E0277]: cannot add-assign `bool` to `bool`
   --> src/main.rs:146:44
    |
146 | ...                   dh_addr.do_send(data);
    |                                       ^^^^ no implementation for `bool += bool`
    |
    = help: the trait `std::ops::AddAssign` is not implemented for `bool`
    = note: required because of the requirements on the impl of `actix::handler::Handler<datahub::Data<bool>>` for `datahub::DataHub`
Valentin
@vroussea
without seeing the code i don't know what's your problem here @hanusek
@biot023 look at FromRequest
Michał Hanusek
@hanusek
Grant Jennings
@gajbooks
What is the correct way to increase the payload limit on a post request? It is trivial for the response, but I cannot find the way for the outgoing payload.
Grant Jennings
@gajbooks
Nevermind, I am just dumb. However, I am now getting the error "broken pipe (os error 32)"
Grant Jennings
@gajbooks
Which is entirely unclear
Running on Mac OS if that helps
Grant Jennings
@gajbooks
Again, it turns out to be my fault, but in this case the true error doesn't even show up when running on OS X. I had to run it on linux. I am communicating with Backblaze and I forgot to percent encode my filename.
Grant Jennings
@gajbooks
It seems that the disconnected socket kills the connection before it can read the error response on some platforms, which is a little odd. Might just be a Tokio socket handling issue.
Adrian Wechner
@adrian-wechner
Hi there, it's a while since I used actix the last time. But I am back at it. Since the last time, all the unfortunate drama happened. I am wondering now, what is the state? Is there a roadmap? Are there specific goals that the project tries to accomplish? With some kind of roadmap, would be easier to contribute. So essentially, what's the roadmap, where can I and others help?
Darin
@Dowwie
@adrian-wechner The actix ecosystem is mature (without a need for re-architecture/refactoring). A small group of motivated people are trying to replace use of unsafe with safe alternatives that don't severely tax performance. This is an important area of work. Issues are being handled as they are reported. Studying the internals of actix-net/actix-web and diagramming the flows would be a valuable exercise not just for learning how the system works but to help others understand as well. The more people that understand actix libraries, the more likely it can be maintained going forward.
Adrian Wechner
@adrian-wechner
@Dowwie Alright. Thanks.
IndrajitSinh Rayjada
@indrajitsinh
Hello, I am fairly new to Actix & Actix-web and rust in general So apologies if I am asking very basic things(I am from Java/C#/PHP Background), Now I have created a basic demo API that has multiple endpoints some of which are required authentication and some of that are not required authentication (i am using JSON web token and actix-identity) Now I have a middleware that checks for authentication and if the user has valid token then request will be successful otherwise it would provide respond error, Right now this is working fine But now I would like to have authorization so that some of the endpoint can be accessible by the user with specific roles (I am using Diesel and have tables of roles/permission) So for each request, middleware is fetching user with its roles/permission and store that information into a struct now I would like to pass that struct to Handler are there any examples of that kind? ( Because the struct can have all the info about the current authenticated user with its role and permission so in Handler I can able to use that struct) Thanks :)

Hello, I am fairly new to Actix & Actix-web and rust in general So apologies if I am asking very basic things(I am from Java/C#/PHP Background), Now I have created a basic demo API that has multiple endpoints some of which are required authentication and some of that are not required authentication (i am using JSON web token and actix-identity) Now I have a middleware that checks for authentication and if the user has valid token then request will be successful otherwise it would provide respond error, Right now this is working fine But now I would like to have authorization so that some of the endpoint can be accessible by the user with specific roles (I am using Diesel and have tables of roles/permission) So for each request, middleware is fetching user with its roles/permission and store that information into a struct now I would like to pass that struct to Handler are there any examples of that kind? ( Because the struct can have all the info about the current authenticated user with its role and permission so in Handler I can able to use that struct) Thanks :)

I can create a custom extractor by using FromRequest trait but then I will fetch information of the user and it's roles/permissions 2 times from the database (1 time from the middleware and 2nd time from the extractor) Thanks :)

vietlib
@vietlib
anybody use actix with mongodb ?
Mehmet ERİBOL
@mehmeteribol_gitlab
hi. i am usin websocket with actix. it works well with local erver but it does not work with nginx. do i have to look at nginx conf or its about actix?
r-arias
@r-arias
@indrajitsinh I think you can use actix-session (https://github.com/actix/actix-extras/tree/master/actix-session) to store the user object in the session. I'm not sure that is the best way to achieve that, but it should work. Maybe someone else has an opinion?
Daksh14
@Daksh14
App::new()
            .data(tera)
            .wrap(middleware::Logger::default()) // enable logger
            .wrap(middleware::NormalizePath)
             .service(
                web::scope("/login")
                    .service(pages::login::login_page)
                    .service(pages::login::login_init),
            )
Doing the NormalizePath doesn't combine trailing slashes.
"login/" and "login" are different and "login" returns not found but "login/" returns something
I want them to be same
Daksh14
@Daksh14
Looks like this is an unresolved issue right now: actix/actix-web#959
Daksh14
@Daksh14
Any workaround for this?
Rob Ede
@robjtede
duplicate the service setup ?
Guillaume Balaine
@Igosuki
Hey guys, I’m looking to run a loop function that pushes metrics regularly to prometheus. I’m isolating it into an actor, with a sync context because it does blocking calls
Any idea how I can properly loop with a timeout ? I dont’ see any lifecycle method where I can just ‘run’ the body of the actor, except in a handler
Jonathas Conceição
@Jonathas-Conceicao
@Igosuki check run_interval it will schedule a closure to run every feel seconds.
Guillaume Balaine
@Igosuki
That’s in AsyncContext
Which means I have to reimplement a lib as async, which I’m finen with
But it would save me some time to just do a blocking call in a sync context
Jonathas Conceição
@Jonathas-Conceicao
If you closure doesn't yield nor spawn other futures it would be blocking too.
Guillaume Balaine
@Igosuki
the lib I want to use is using reqwest
which builds another tokio runtime inside itself
Guillaume Balaine
@Igosuki
ok async await it is then
Guillaume Balaine
@Igosuki
so my next question, can I spawn an async block with an AsyncContext ?
Guillaume Balaine
@Igosuki

ctx::spawn expects everything to be static, how can I initialize an http client in my Actor and reference it ? so far I have to make everything static which isn’t ideal…

ctx.run_interval(self.push_frequency,  |a, c| {
            c.spawn(push_metrics().into_actor(a));
        });

how can I do
push_metrics(a.client).into_actor(a) instead ?

Jonathas Conceição
@Jonathas-Conceicao
You can do that if you can move the client to the closure or borrow it from the actor's internal state.