Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 03:15

    github-actions[bot] on gh-pages

    Deploying to gh-pages from @ b… (compare)

  • 03:12

    JohnTitor on master

    Remove CoC on actix-http as dup… (compare)

  • 03:11

    github-actions[bot] on gh-pages

    Deploying to gh-pages from @ e… (compare)

  • 03:09

    github-actions[bot] on gh-pages

    Deploying to gh-pages from @ 5… (compare)

  • 03:09

    JohnTitor on master

    Update CoC contact information (compare)

  • 03:07

    JohnTitor on master

    Update CoC contact information (compare)

  • 02:42

    github-actions[bot] on gh-pages

    Deploying to gh-pages from @ 2… (compare)

  • 02:39

    robjtede on master

    fix deps.rs badge (compare)

  • Oct 30 20:35
    codecov-io commented #1767
  • Oct 30 20:33
    codecov-io commented #1767
  • Oct 30 20:31
    codecov-io commented #1767
  • Oct 30 20:31
    codecov-io commented #1767
  • Oct 30 20:19
    fakeshadow closed #380
  • Oct 30 20:19
    fakeshadow commented #380
  • Oct 30 20:13
    Sebmaster commented #1767
  • Oct 30 20:12
    Sebmaster synchronize #1767
  • Oct 30 20:12
    neilyoung commented #1766
  • Oct 30 20:12
    Sebmaster synchronize #1767
  • Oct 30 20:11
    neilyoung commented #198
  • Oct 30 20:11
    robjtede commented #1766
Paul Kassianik
@paulkass
Hey guys, wondering if there's any documentation to handle file uploads in Post requests?
2 replies
zero-systems
@zero-systems
How do I get current tokio/actix-rt loop inside HttpServer::new(move || App::new()?
3 replies
For each worker
I need to do some async actions while creating .data
Alan Briolat
@alanbriolat
Is there an upperbound on what a sensible number of actors is, either in terms of performance or just "you're doing it wrong"?
10 replies
Alan Briolat
@alanbriolat
I'm playing around with trying to build a BitTorrent client, which is obviously a pretty IO-bound use case. My thoughts so far are that the logical division of responsibilities, and therefore actors, is a single Session actor (which is the entry point for the frontend communicating with the core), a Torrent actor per loaded torrent (potentially thousands), a Peer actor per known peer (tens of thousands, only a few hundred of which would have active connections at any one time), and some mechanism to globally limit simultaneous connection count and file handle count.
Does this sound sensible, or like I should be considering pooling things into fewer actors, or not even using the actor model at all?
WiredSharp
@WiredSharp
Hi all, as a Rust Newbie, i tried to build a web site with actix-web. I wanted to process default url to index.html. So i decided to write a middleware to do the job. To modify the Request uri, i followed what was done in Normalize middleware but it looks to me a lot of code to change the path of the request, isn't there any simpler way to do this?
2 replies
Kevin Hoffman
@autodidaddict
I'm sure this has been asked a million times... I've got a synchronous function (mandatory, it's an FFI callback) that needs to make a call into the actor system, await the result, and then return the result. I've tried all forms of "block_on" that I can think of and none of them work. What's the right way to "de-async" a call to an actor?
3 replies
Bernard Labno
@blabno
expected struct Box, found struct Pin
Bernard Labno
@blabno
I've noticed that for ResponseFuture the Box::pin works, but for ResponseActFuture the Box::new is needed instead
17 replies
Bernard Labno
@blabno
btw. I am looking for someone to review ~1k lines of my actix code, I'm willing to pay for the job.
Bernard Labno
@blabno
Is it possible to convert ActorFuture to Future?
7 replies
Brian Victor
@brianhv
are there any reasonably mature solutions for (customer) authentication and identity management? basically looking to fill the role that django auth does, with login/registration/password reset/etc. should I be looking at something like AWS Cognito with OIDC?
Cris Liao
@clia
SSE long-polling connection server using Actix-web 3.0.2, while the clients use Java & okhttp lib, the server can support concurrent connections more than 400K; but when the clients use C++ & libcurl, when concurrent connections add up to 130K, the server will hangs on and logging:
"Service 0.0.0.0:443 is unavailable"
Accepting connections on 0.0.0.0:443 has been resumed
Anybody knows where the problem is?
ghostff
@Ghostff

Hi guys, I have this struct (diesel):

#[table_name = "users"]
#[derive(Insertable, Debug)]
pub struct NewUser<'a> {
    pub first_name: &'a str,
    pub last_name: &'a str,
}

let m = NewUser {
    first_name: "Foo",
    last_name: "Bar",
};

But am wondering why, I can do this:

let user: User = diesel::insert_into(...).values(&m).get_result(conn).expect(...);

But not this:

impl<'a> NewUser<'a> {
    pub fn create( & self, conn: &PgConnection) -> self::User {
        diesel::insert_into(...).values(self).get_result(conn).expect(...)
    }
}

m.create(conn);
1 reply
Tom CHEN
@surfingtomchen
Hi guys, is there any comprehensive example of actix-net? I'm quite new for the rust and seeking help to use actix-net framework to build my tcp server. TIA.
6 replies
Geometrically
@Geometrically
Hey, is there any examples/projects which use Auth0 for authentication?
1 reply
KOKOU AFIDEGNON
@afidegnum
hi, how do i extract data from web::data pool ?
1 reply
Geometrically
@Geometrically
How can I pass data from a middleware to a route?
1 reply
junefar
@junefar
Hi, How do I stop an actor with internal loops,sending a message doesn't work.
For example ,I use amiquip with actor, I can't stop it.
        for (_i, message) in consumer.receiver().iter().enumerate() {
            match message {
                ConsumerMessage::Delivery(delivery) => {
                    let msg = delivery.body.clone();
                    let foo = String::from_utf8(msg).unwrap();
                    let data = foo.to_string();
                    let k: Value = serde_json::from_str(&data).unwrap();
                    ctx.stop(); // doesn't work
                }
                other => {
                    println!("Consumer ended: {:?}", other);
                    break;
                }
            }
        }
33 replies
Pankaj Jangid
@jangid
/quit
Jonathan
@MonliH

Hi, how can I have resolve like functionality with actix-web? I want to get the server to send the www/build/index.html file if the file requested isn't in www/build. This code doesn't work:

#[get("/*")]
async fn home(_req: HttpRequest) -> io::Result<NamedFile> {
    Ok(NamedFile::open("www/build/index.html")?)
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new()
            .service(Files::new("/*", "www/build/"))
            .service(home)
    })
    .bind("127.0.0.1:8080")?
        .run()
        .await
}

The above code just tries to get the file from www/build, but then returns a 404 instead of trying the home service. Is there an easy way I can "chain" these?

Jonathan
@MonliH
Actually nevermind, I'm not sure why I didn't take a look at the API docs. It's pretty clear there;.default_handler(web::route().to(home))) did the job for me
dave-a-hawkins
@dave-a-hawkins
Hey ya'll! I'm using actix-web = "3" and actix-multipart = "0.3" and getting some weird behavior trying to upload a file - I can only seem to get the file name out of the payload.
dave-a-hawkins
@dave-a-hawkins

pub async fn test2(
mut payload: Multipart,
) -> Result<String, Error> {

let mut response_details: Vec<String> = vec![];
let mut result = String::from("");

while let Some(item) = payload.next().await {
    let mut field = item?;
    let mut myFileStream: Vec<u8> = vec![];


    // Field in turn is stream of *Bytes* object
    while let Some(chunk) = field.next().await {
        let mut data = chunk.unwrap().to_vec();
        myFileStream.append(&mut data);
    }

    println!("{}",
        format!("{:?}", myFileStream)
    );
}

}

myFileStream ends up only containing the name of the source file from the client.
49 replies
hakan-geijer
@hakan-geijer
Hi. I'm using actix-web 3 and actix-web-actors 3 and I have questions about websockets that both reply to incoming messages and pull from (for example) an AMQP queue. I'm trying to figure out what pattern works for this. I'm guessing it needs to be something like using ws::start_with_addr and passing the addr to a thread::spawn with an infinite loop that keeps sending to the WS actor until it gets an error. I don't see another clear way to do this. Anyone have suggestions?
16 replies
K0R0VA
@K0R0VA

Hello, i wanna make some function like this. Can you give me advice?

pub struct AppState {
pub db : Addr<PgActor>,
}

fn GetResponce<'de, I, F>(state : web::Data<AppState>, input : web::Json<I>, foo : F ) -> impl Future
where I : Deserialize<'de>,
F : Fn(Data<AppState>, Json<I>) -> Result<HttpResponse, Error> {
web::block ( move || foo (state, input))
}

mtkastner
@mkastner

Is there any documentation available on how to deploy an actix application on FreeBSD. Maybe with examples for rc.d scripts, etc. I find a lot of examples of how to deploy to docker containers or on heroku but I haven't found anything on plain old self hosting (yeah, redhat, that's right I'm a greybeard).

If anyone could point me to some docs or examples, that'd be awesome.

sparky8251
@sparky8251
does anyone have code that shows how i can stuff actix-web into a tokio task? ive got an application in mind where i need to have both actix and period tasks accessing the database separately so ive wanted to make the scheduler and web server distinct tasks. actix seems to hate the very idea of me initializing it in a task however and is fighting me at every turn
7 replies
Geometrically
@Geometrically
Is there any rate limiting libraries for actix web?
4 replies
Geometrically
@Geometrically
How can I make a response send a permanent redirect? https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
1 reply
Alan Briolat
@alanbriolat
Am I missing something, or does AsyncContext::spawn() just assume you'll never spawn enough things to overflow usize? Is this a documented limitation?
12 replies
matrixbot
@matrixbot
MTRNord Hi anyone knows a good way to make auth with actix-web? I have a page using askama templates served using actix-web and want to add a admin page where I need some kind of proper auth for it. So I am wondering what the best or easiest way might be to do that 🤔
MTRNord So basicly 2 things. The easier part being a api behind auth and a frontend that only gets send when the user is allowed to view that page
matrixbot
@matrixbot
robjtede * MTRNord: check out actix-session and actix-identity
MTRNord Hm just found https://github.com/HeroicKatora/oxide-auth I guess that would be a more complete solution using oauth2 🤔
Jonas Platte
@jplatte
There's also actix-web-httpauth, which I guess is lower-level based on the names of the other two?
Also totally forgot all of gitter is bridged to Matrix! Bye Gitter tab :3
matrixbot
@matrixbot
jplatte Ah, much better :)
Tomas Ostasevicius
@to266

Hi, I'm struggling with #[actix_rt::test] and lazy_static(or the equivalent) + reqwest.

What I'd like to do, is fetch a string from external service (a token decoded from JWT), stick it into a lazy_static, and re-use it for the testing session. Before reqwest had async and blocking clients, it worked as expected.

With reqwest >= 0.10, however, event the blocking client does some thread or runtime magic, resulting in the annoying Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context. error.

I'd really like to keep the state and not re-fetch the token with every test, though.

9 replies
matrixbot
@matrixbot
jplatte Tomas Ostasevicius (Gitter): You could use a truly blocking client like ureq, but why is it a problem to do multiple requests anyway?
1 reply
jplatte Or more accurrately, a client not dependent on an async runtime
jplatte Having tests that rely on an external service seems like a really bad idea
1 reply
jplatte That's how you generate more work for people triaging crater results