Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 05:57
    pangwa commented #291
  • Oct 21 20:55
    thedodd commented #291
  • Oct 21 17:42
    kathampy edited #1146
  • Oct 21 17:38
    kathampy edited #1146
  • Oct 21 17:37
    kathampy opened #1146
  • Oct 21 16:37
    asyade commented #1122
  • Oct 21 14:19
    pangwa opened #291
  • Oct 21 13:30
    hogum commented #1145
  • Oct 21 13:30
    hogum commented #1145
  • Oct 21 03:48
    fafhrd91 commented #1122
  • Oct 21 03:47
    fafhrd91 commented #1138
  • Oct 21 03:44
    fafhrd91 commented #1140
  • Oct 20 19:05
    sabahtalateh commented #1140
  • Oct 20 14:27
    Jonathas-Conceicao synchronize #1130
  • Oct 20 08:48

    fafhrd91 on gh-pages

    Documentation upload (compare)

  • Oct 20 08:40

    JohnTitor on master

    Upgrade `derive_more` to 0.15.0… (compare)

  • Oct 20 08:40
    JohnTitor closed #290
  • Oct 20 08:40
    JohnTitor closed #265
  • Oct 20 05:08
    fafhrd91 commented #1130
  • Oct 20 05:08
    fafhrd91 commented #1136
starfear
@starfear

...
19 | /         web::Form::<TokenData>::extract(&req)
20 | |             .map_err(|e| {
21 | |                 Error::from(
22 | |                     HttpResponse::build(StatusCode::UNAUTHORIZED)
...  |
36 | |                 }
37 | |             })
| |__^ expected enum std::result::Result, found struct futures::future::map::Map
Nikolay Kim
@fafhrd91
You return different type from what you declare in Self::Future
Return Box<dyn Future<...>>
starfear
@starfear
seems like it's working ty
Bagus Santoso
@bagusyuu_gitlab
hi, i've questions about actix-web query. is it possible for actix web Query Parameter handling dynamic query? as an example, i want to sent parameter of 1 family, which some families only have 1 child while the others have 3/4 child, n some other cases, some families only have single parents. do you have any suggestion for me how to handle this kind of cases using actix-web query? or should i use another approach (with using serde_json for parsing parameter that sent to server)? or another approach? many thanks for your help.
Nikolay Kim
@fafhrd91
Just parse it manually
Daniel Egger
@therealprof
Still trying to wrap my head around how to spawn a Handler from an HTTP request and wait for the Result. Are there any pointers how I can turn my Handler into the Future I'm returning?
Nikolay Kim
@fafhrd91
You just return future
Daniel Egger
@therealprof
So I'm starting a new Actor inside my HTTP endpoint handler, that works fine. But how do I tie the Actor into a future?
The Actor works in a pub sub fashion. It sends out a request over an async interface and will receive a Message with a result, and that result needs to be part of the HTTP response.
Nikolay Kim
@fafhrd91
Usually actors are long living entity, you just use addr to send messages
Daniel Egger
@therealprof
Sure, but where would I send the Message to if I don't have an Actor? Just sending out a Message would work fine for me, but I need to wait for a different Message with the reply.
That's why I'm firing up an Actor so I have an Addr I can send the reply to.
I'd be happy if there was an easier way.
Nikolay Kim
@fafhrd91
Start an actor at the start of the app
Otherwise you use actix in wrong way
Daniel Egger
@therealprof
I'd be grateful if you could point me at the right way. The protocol I want to adapt to is pub-subish, I can't change that. I already have Actors to do a telnet interface and a database interface. Now I want to do a REST interface but I'm failing to synchronise this...
I could do a custom HTTP handler but I'm not sure that is what you're suggesting.
Daniel Egger
@therealprof
NB: The websocket-tcp-chat example also creates an Actor per incoming connection, so I had the impression that is an okay thing to do.
Daniel Egger
@therealprof
Is that something that might help me to let a persistent Actor handle the situation?
Mohammed Abubakar
@moh-abk

what is the correct way of getting headers from a request?

i'm getting the trait _IMPL_DESERIALIZE_FOR_IndexRequest::_serde::Serialize is not implemented for actix_web::http::HeaderMap

Nikolay Kim
@fafhrd91
Use HttpRequest
Piotr Płaczek
@piotr-placzek
Hi there, maybe someone can help me ?
Nikolay Kim
@fafhrd91
use Bytes extractor or web::Payload
Piotr Płaczek
@piotr-placzek
With web::Payloadparam i have this same error, but Bytes extractor works fine
This message was deleted
Thanks ;)
MarcBoud
@MarcBoud
Does actix-web implement a zero copy upgrade to websocket? (Like: https://github.com/gobwas/ws ). If not, is there any interest in me working on it? (I'm not really skilled in the matter, but I can try if there are people beside me who need it)
Guang
@pangwa
hello, I met a deadlock while trying to send sync message to another actor from an actor.
I'm trying to fix it using request.into_actor(), but it doesn't compiles..
let req = self.addr.send(GetReceiveAddress{});
let result  = req.into_actor(self).wait(_ctx); // it failed at this line,
how to fix it? any idea?
Chris Lucas
@cjlucas
Can you try:
let req = self.addr.send(GetReceiveAddress{});
let f  = req.into_actor(self) // you may need to .map_err(|_| ()) as well
ctx.wait(f);
Jussi Norlund
@jmn
Is there an actix reverse proxy?
Guang
@pangwa
@cjlucas This works, actor waits for the future, but it seems the result is missing because wait has a result of ()...
Rich Murphey
@rich-murphey
if actix is bound to all interfaces, such as HttpServer::new(...).bind("0.0.0.0:80"), and you want a list of the bound addresses, should you get it from the server, or get it from getaddrs()?
seems there is no point to add api docs
Rich Murphey
@rich-murphey
yea, server.addrs() returns "0.0.0.0", so I'm wondering whether one needs to use libc getaddrs().
Nikolay Kim
@fafhrd91
addrs returns SocketAddr, it contains port https://doc.rust-lang.org/nightly/std/net/enum.SocketAddr.html
Rich Murphey
@rich-murphey
The API for addrs() says "Get addresses of bound sockets.", but it actually returns "0.0.0.0:80".
Daniel Egger
@therealprof
@rich-murphey Seems right to me. If you bind the server to any IP(v4) port 80, the address it is bound to is 0.0.0.0:80.
Mohammed Abubakar
@moh-abk
any way to get around this? - std::rc::Rc<actix_web::request::HttpRequestInner> cannot be sent between threads safely
pub fn logout(req: HttpRequest) -> impl Future<Item = HttpResponse, Error = ServiceError> {
    web::block(move || {
        let r = req.clone();
        let header = r.headers().get("Authorization").unwrap();
        let token = &header.to_str().unwrap()[7..];
        logout_query(&token.to_string())
    })
    .then(|res| match res {
        Ok(_) => Ok(HttpResponse::Ok().json(LogoutResponse {
            message: "logout successful".to_string(),
        })),
        Err(err) => match err {
            BlockingError::Error(service_error) => Err(service_error),
            BlockingError::Canceled => {
                error!("admin login: {:?}", err);
                Err(ServiceError::InternalServerError)
            }
        },
    })
}
fakeshadow
@fakeshadow
pass your token string to web::block
Mohammed Abubakar
@moh-abk
like this @fakeshadow? ;
pub fn logout(req: HttpRequest) -> impl Future<Item = HttpResponse, Error = ServiceError> {
    let r = &req.clone();
    let header = req.headers().get("Authorization").unwrap();
    let token = &header.to_str().unwrap()[7..];

    web::block(move |token| logout_query(&token.to_string())).then(|res| match res {
        Ok(_) => Ok(HttpResponse::Ok().json(LogoutResponse {
            message: "logout successful".to_string(),
        })),
        Err(err) => match err {
            BlockingError::Error(service_error) => Err(service_error),
            BlockingError::Canceled => {
                error!("logout: {:?}", err);
                Err(ServiceError::InternalServerError)
            }
        },
    })
}
fakeshadow
@fakeshadow
the token is moved to closure. not given by closure. So it should be web::block(move || /* your code */)
and you should make it a string before move it
&str is not Send either