Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 17 12:13
    cv1002 closed #511
  • Sep 17 12:13
    cv1002 commented #511
  • Sep 15 17:49
    thalesfragoso commented #511
  • Sep 15 15:08
    robjtede commented #2388
  • Sep 15 15:01
    ArunGust commented #2388
  • Sep 15 11:52
    LukeMathWalker commented #2376
  • Sep 14 16:25
    fakeshadow commented #2386
  • Sep 14 16:25
    fakeshadow closed #2386
  • Sep 14 16:25
    fakeshadow commented #2386
  • Sep 14 16:16
    fakeshadow commented #2386
  • Sep 14 16:03
    fakeshadow commented #2386
  • Sep 14 11:07
    robjtede labeled #2388
  • Sep 14 11:06
    robjtede labeled #2328
  • Sep 14 11:06
    robjtede commented #2388
  • Sep 14 11:06
    robjtede closed #2388
  • Sep 14 11:06
    robjtede commented #2388
  • Sep 14 02:55
    ArunGust opened #2388
  • Sep 13 21:24
    ibraheemdev labeled #2387
  • Sep 13 21:24
    ibraheemdev labeled #2387
  • Sep 13 21:24
    ibraheemdev opened #2387
magnus
@magnusja
Hey there, is there a way to error if there are additional keys in the json body which are not contained inside the struct wrapped around web::Json?
3 replies
Currently we have the problem that a typo or whatever confusion results in a silent fail
because all our fields are optional
oloshe
@oloshe:matrix.org
[m]
I just try to write a handle with Result = ResponseActFuture, and return a Box::pin, but idk how can i send an actor Request and wait its result to operate a return value in async block. Anyone know?
Chris Allen
@bitemyapp
I posted a little trait I made for error handling in actix-web that some of you might find helpful: https://old.reddit.com/r/rust/comments/ozc0m8/an_actixanyhow_compatible_error_helper_i_found/
Bogumil Bialous
@bogumbiker_twitter
Looking for an examples how to use query extractors and customising its errors messages. We need to capture query validation errors and translate it to our custom Error response.
Found this: https://docs.rs/actix-web/4.0.0-beta.8/actix_web/web/struct.QueryConfig.html but some examples would definitely help as still in learning mode -> rust and actix.
Impossible Reality
@impossiblereality:matrix.org
[m]
is there any easy way to make custom session stores in actix_session?
Kunjan Dalal
@kunjee17
Screenshot 2021-08-31 at 9.32.20 AM.png
Actix files are working in development. Tested in target folder it is working. But some how not working inside docker. I m literally out of ideas. Any help?
Fabio
@f4bio:matrix.org
[m]
Probably need way more information...
Works for me
Do you have a sample application?
Kunjan Dalal
@kunjee17
It works for me out side of docker.
But 404 inside docker.
SS is from docker image it self.
server and open_api both are at same locaiton
location
Fabio
@f4bio:matrix.org
[m]
404 should give you some direction where to look at
also, put ENV RUST_LOG=debug in your Dockerfile and run with docker run -it --rm yourimage:latest
like I said, it works fine for me. has to be somewhere at your implementation
without demo/sample project with your code its quite hard to help you much further
there is also a working example in official actix-examples
daniel
@daniel:nopemail.org
[m]
The container probably doesn't have access to the files. They are not compiled into the binary.
Kunjan Dalal
@kunjee17
They are not . I m copying seperately
Code is pretty simple.
use actix_files::Files;
use actix_web::web;

pub fn config(cfg: &mut web::ServiceConfig) {
    // cfg.service(docs).service(spec);
    cfg.service(Files::new("", "./open_api").index_file("index.html"));
}
I m not doing anything fancy
And open_api folder is at root level
2 replies
out side of src
Fabio
@f4bio:matrix.org
[m]
maybe try:
    cfg.service(Files::new("/", "./open_api").index_file("index.html"));
I'm not sure what happens if mount path is empty
Also wasn't there something like show_file_listing() to list content of folders?
Files::new probably expects a file as second param?
I'm on mobile right now, can't check. Sorry
Kunjan Dalal
@kunjee17
Thanks for help @f4bio:matrix.org . No hurries. I m returning json as hardcoded string for now. I ll check out your solution as well.
Fabio
@f4bio:matrix.org
[m]
and when you run the rust image, your home is /home/rust/src or something
Kesav Kolla
@kesavkolla
Is actix actors still a way to run long running tasks? I have a heay duty process which requires some parallel processing. The API endpoint is actix-web and once I receive a request I need to run parallel jobs to get the data. The data is then sent back as a result to API end point. I was thinking to create an actor which can then run in parallel with main thread. Is it right way of going about it?
1 reply
Fabio
@f4bio:matrix.org
[m]
uh. I hope somebody with deeper knowledge than me (than I? :D) can answer that
I tried something similar a while ago
used something similar to this (first google result ;D)
kind of worked. ultimately I switched to schedule based tasks
publicarray
@publicarray:matrix.org
[m]

Hi, how can I serve static files without the html extension. aka clean URLs? This is required for some web frameworks, I'm trying to serve nextjs after exporting the build. I already have

.service(fs::Files::new("/", "frontend/dist").index_file("index.html").prefer_utf8(true)

Basically I want the behaviour as if the /foo.html was served from /foo/index.html

husk_
@husk_:matrix.org
[m]

Hey there! I'm trying to learn about websockets, and I've been referring to the docs but the example code is out of date!

https://github.com/actix/examples/tree/master/websockets/websocket

Uses actix v0.10 instead of the latest, and there is seemingly a breaking change to the example code when trying to run with 0.12

1 reply
KOKOU AFIDEGNON
@afidegnum
hi, can you please give a hint on this traceback? actix abnormally terminating, I can't fathom the cause of it not compiling. https://dpaste.org/GLBn
14 replies
Fabio Lama | W3F
@fabio:web3.foundation
[m]
the tokio versioning transition has been a huge pain in the Rust ecosystem...
Fabio Lama | W3F
@fabio:web3.foundation
[m]
Just make sure you keep your Cargo.lock
Syahrul Ardiansyah
@sfardiansyah__gitlab
Hi there! Is there anyone know how or the scripts to deploy a latest beta version actix server to Google Cloud Run? I've tried a simple hello world server, works well on the local, but the deployment was timed out.
2 replies
liam-prog
@liam-prog

Hi, I used actix-web-httpauth = "0.5.1" but i got this error

error[E0631]: type mismatch in function arguments
   --> src/main.rs:83:43
    |
52  | async fn validator(req: ServiceRequest, credentials: BearerAuth) -> Result<ServiceRequest, Error> {
    | ------------------------------------------------------------------------------------------------- found signature of `fn(ServiceRequest, BearerAuth) -> _`
...
83  |     let auth = HttpAuthentication::bearer(validator);
    |                                           ^^^^^^^^^ expected signature of `fn(actix_web::service::ServiceRequest, BearerAuth) -> _`
    |
note: required by `HttpAuthentication::<BearerAuth, F>::bearer`
   --> /home/liam/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-httpauth-0.5.1/src/middleware.rs:116:5
    |
116 |     pub fn bearer(process_fn: F) -> Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

actix = "0.12.0"
actix-web = { version = "4.0.0-beta.9", default-features = false}
actix-rt = "2.2.0"
actix-service = "2.0.0"
actix-http = "2.2.0"

Stefan Lauer
@Algorab

Hi, I am rather new with Rust and actix.
I have an actor under test an it sents a message to an other actor which is mocked with the Mocker.

let mocker = Mocker::<RgbSensor>::mock(
                Box::new(move |_msg: Box<dyn Any>, _ctx| {
                   let res = match _msg.downcast::<Start>() {
                        Ok(_) => {Some(())},
                        Err(_) => {
                            //Error should fail the test
                          None::<()>
                        }
                    };

                    Box::new(res)
                })
            );

When None is returned the Mocker produce a panic, this panic don't let the test fail.
How can it achieved that the test get fail, when the actor under test sends a wrong message or the message is never sent. Hope somebody can point me to the right direction.