#how to configure actix_web 4.1 via toml

13 messages · Page 1 of 1 (latest)

plush wharf
#

So my task is to update a Rust project using actix_web 3.1 to current 4.1. I had to replace the client, but that work out fine. But now the problem is that the project uses actix-settings https://crates.io/crates/actix-settings for configuring the HttpServer via a toml file. Unfortunately actix-settings hasn't been updated recently and the latest version still only supports actix_web 3.1.

Of course I could simply remove that dependency and move the configuration into the code, but is there maybe another crate that took over from actix-settings and supports configuration via toml (or via another file format)?

PS: I cloned actix-settings and checked if I can simply update its dependency to actix-web 4.1 but this seems to require non-trivial code changes as well, so it's not really an option for me.

fiery hawk
#

since it's a community crate, cloning and updating it is your best option unless it's easier to replicate its function manually

fiery hawk
#

i can help with specific queries while updating if you need

plush wharf
fiery hawk
#

i know it's not immediately helpful but seems like an interesting crate to have

plush wharf
#

@fiery hawk ok, let's maybe try to fix this in actix-settings after all. 1 of the 2 issues reported by cargo check was trivial, the remaining one might be due to several versions of actix-service being referenced (1.0.6 and 2.0.2).

stephan@londux:~/workspace/rust/actix-settings$ cargo check
    Checking actix-settings v0.6.0 (/home/stephan/workspace/rust/actix-settings)
error[E0107]: missing generics for trait `actix_web::dev::Service`
   --> src/lib.rs:197:20
    |
197 |     <S::Service as Service>::Future: 'static,
    |                    ^^^^^^^ expected 1 generic argument
    |
note: trait defined here, with 1 generic parameter: `Req`
   --> /home/stephan/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-service-2.0.2/src/lib.rs:93:11
    |
93  | pub trait Service<Req> {
    |           ^^^^^^^ ---
help: add missing generic argument
    |
197 |     <S::Service as Service<Req>>::Future: 'static,
    |                    ~~~~~~~~~~~~

You can find my current forked/semi-fixed version of the crate here: https://github.com/simon-void/actix-settings

GitHub

Contribute to simon-void/actix-settings development by creating an account on GitHub.

#

the where-clause of ApplySettings is too advanced to me to mentally parse. I only understand the first 3 lines

impl<F, I, S, B> ApplySettings for HttpServer<F, I, S, B>
where
    F: Fn() -> I + Send + Clone + 'static,
    I: IntoServiceFactory<S>,
    S: ServiceFactory<Config = AppConfig, Request = Request>,
    S::Error: Into<WebError> + 'static,
    S::InitError: Debug,
    S::Response: Into<Response<B>> + 'static,
    <S::Service as Service>::Future: 'static,
    B: MessageBody + 'static

So when ich ctrl+click on Service I'm directed to a version of it that requires one generic parameter (and which is located in actix-service:2.0.2). But when I ctrl+click on HttpServer->ServiceFactory(in where-clause)-> Service I land on a version without generic parameter (and which is located in actix-service:1.0.6). And HttpServer itself comes from actix-web:3.3.3 even though I requested 4:1. very strange/unfamiliar.

fiery hawk
#

alright, we have liftoff

plush wharf
#

wow, you updated so much!! 🤯 🥳

plush wharf
#

and made actix-settings an "official" actix crate 🤯 🥳 This feels so uneal to me! thank you so much!