Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 19:42
    robjtede labeled #1755
  • 19:41
    robjtede demilestoned #1721
  • 19:40
    jplatte closed #1721
  • 19:40
    jplatte commented #1721
  • 19:14
    codecov-io commented #1754
  • 18:55
    robjtede commented #1721
  • 18:54
    robjtede commented #1251
  • 18:54
    robjtede commented #1251
  • 18:54
    robjtede commented #1251
  • 18:54
    robjtede commented #1735
  • 18:53
    robjtede commented #1727
  • 18:46
    robjtede commented #1754
  • 18:44
    robjtede commented #1754
  • 18:44
    robjtede commented #1754
  • 18:43
    robjtede edited #1754
  • 18:42
    robjtede synchronize #1754
  • 18:42

    robjtede on on-connect

    fix populate extensions for htt… (compare)

  • 15:28
    robjtede commented #1754
  • 12:59
    robjtede commented #1754
  • 11:42

    github-actions[bot] on gh-pages

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

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
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
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?
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
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
expected struct Box, found struct Pin
Bernard Labno
I've noticed that for ResponseFuture the Box::pin works, but for ResponseActFuture the Box::new is needed instead
17 replies
Bernard Labno
btw. I am looking for someone to review ~1k lines of my actix code, I'm willing to pay for the job.
Bernard Labno
Is it possible to convert ActorFuture to Future?
7 replies
Brian Victor
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
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 is unavailable"
Accepting connections on has been resumed
Anybody knows where the problem is?

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 {

1 reply
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
Hey, is there any examples/projects which use Auth0 for authentication?
1 reply
hi, how do i extract data from web::data pool ?
1 reply
How can I pass data from a middleware to a route?
1 reply
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);
33 replies
Pankaj Jangid

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:

async fn home(_req: HttpRequest) -> io::Result<NamedFile> {

async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
            .service(Files::new("/*", "www/build/"))

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?

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
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.

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);

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


myFileStream ends up only containing the name of the source file from the client.
49 replies
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

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))


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.

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
Is there any rate limiting libraries for actix web?
4 replies
How can I make a response send a permanent redirect? https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
1 reply
Alan Briolat
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
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
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
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
jplatte Ah, much better :)
Tomas Ostasevicius

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
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
jplatte Tomas Ostasevicius (Gitter): #[test] is for unit tests, not integration tests. It really isn't designed for having some global setup run before all tests