Official Discord: https://discord.gg/NWpN5mmg3x | Powerful web framework for Rust | https://github.com/actix/actix-web/wiki/FAQ
robjtede on master
tweak migration document (compare)
github-actions[bot] on gh-pages
Deploying to gh-pages from @ 5… (compare)
github-actions[bot] on gh-pages
Deploying to gh-pages from @ f… (compare)
robjtede on test-v0.1.0-beta.13
robjtede on http-test-v3.0.0-beta.13
robjtede on master
prepare actix-http-test release… prepare actix-test release 0.1.… (compare)
github-actions[bot] on gh-pages
Deploying to gh-pages from @ a… (compare)
robjtede on actors-v4.0.0-beta.12
robjtede on master
prepare actix-web-actors releas… (compare)
robjtede on awc-v3.0.0-beta.21
robjtede on master
prepare awc release 3.0.0-beta.… (compare)
robjtede on http-v3.0.0-rc.3
robjtede on master
prepare actix-http release 3.0.… (compare)
async
? Or is it not useful?
#[get("/api/endpoint1")]
async fn api_request() -> Result<String> {
Ok(String::from("Hello World"))
}
#[post("/login")]
async fn post_login(user: Data<LoginUser>) -> Result<HttpResponse, Error> {
Ok(HttpResponse::Ok().json(1))
}
.service(web::resource("/login").route(web::post().to(post_login)))
| -- ^^^^^^^^^^ the trait `Handler<_, _>` is not implemented for `post_login`
| |
| required by a bound introduced by this call
Sorry have another question, just wondering if i can improve the code ergonomics a little. Prior to upgrading i'd have code like this:
let (game, rounds) = block(move || {
let game = Game::find_by_id(&connection, game_id)?;
let rounds = Round::belonging_to(&game).load::<Round>(&connection)?;
Ok((game, rounds))
})
.await?;
Now with the changes to block(), it wraps the result for me. Since i want errors to return from the db operations there, i want to keep my own result. But this makes for a bit more code:
let data: Result<(Game, Vec<Round>), Error> = block(move || {
let game = Game::find_by_id(&connection, game_id)?;
let rounds = Round::belonging_to(&game).load::<Round>(&connection)?;
Ok((game, rounds))
})
.await?;
let (game, rounds) = data?;
HttpServer::new(move || {
let auth = HttpAuthentication::bearer(bearer_auth_validator);
App::new()
.app_data(state.clone())
.wrap(middleware::Logger::default())
.wrap(auth)
.service(put_job)
.service(next)
})
I got an application like this. I would like to put the auth
only with the two services, and add another service without the bearer authentication. How would I go about that?
Fiddled a bit with it, looks like
HttpServer::new(move || {
let auth = HttpAuthentication::bearer(bearer_auth_validator);
App::new()
.app_data(state.clone())
.wrap(middleware::Logger::default())
.service(metrics)
.service(web::scope("").wrap(auth).service(next).service(put_job))
})
works
res.map_body(...)
(line 321) which you can use to wrap the stream in your own struct with other bits you'll need when the stream is done
I was wondering what the best way of encrypting proxied data through websockets would be.
I'm essentially making a proxy, but I don't want to be able to see the data.
I was thinking about implementing a TLS-like handshake, but then the server still gets both certificates and the encryption is breakable.
I'm going to be sending passwords and usernames through the network and the only server-side processing I'm going to be doing is mapping WSS streams to a random id.
.guard(guard::fn_guard(|req| is_logged(req.get_session())))