-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
744 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
[package] | ||
name = "actix-web-httpauth" | ||
version = "0.8.1" | ||
description = "HTTP authentication schemes for Actix Web" | ||
categories = ["web-programming"] | ||
keywords = ["http", "web", "framework", "authentication", "security"] | ||
authors = [ | ||
"svartalf <[email protected]>", | ||
"Yuki Okushi <[email protected]>", | ||
] | ||
description = "HTTP authentication schemes for Actix Web" | ||
keywords = ["http", "web", "framework", "authentication", "security"] | ||
homepage = "https://actix.rs" | ||
repository = "https://github.com/actix/actix-extras.git" | ||
categories = ["web-programming::http-server"] | ||
repository = "https://github.com/actix/actix-extras" | ||
license.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Changelog | ||
|
||
## Unreleased | ||
|
||
- Remove type parameters from `Session::{text, binary}()` methods, replacing with equivalent `impl Trait` parameters. | ||
- `Session::text()` now receives an `impl Into<ByteString>`, making broadcasting text messages more efficient. | ||
|
||
## 0.2.5 | ||
|
||
- Adopted into @actix org from <https://git.asonix.dog/asonix/actix-actorless-websockets>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[package] | ||
name = "actix-ws" | ||
version = "0.2.0" | ||
description = "WebSockets for Actix Web, without actors" | ||
categories = ["web-programming::websocket"] | ||
keywords = ["actix", "web", "websocket", "websockets", "http"] | ||
authors = [ | ||
"asonix <[email protected]>", | ||
"Rob Ede <[email protected]>", | ||
] | ||
repository = "https://github.com/actix/actix-extras" | ||
license.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
|
||
[dependencies] | ||
actix-codec = "0.5" | ||
actix-http = { version = "3", default-features = false, features = ["ws"] } | ||
actix-web = { version = "4", default-features = false } | ||
bytestring = "1" | ||
futures-core = "0.3.17" | ||
tokio = { version = "1", features = ["sync"] } | ||
|
||
[dev-dependencies] | ||
actix-rt = "2.6" | ||
actix-web = "4.0.1" | ||
anyhow = "1.0" | ||
futures = "0.3" | ||
log = "0.4" | ||
pretty_env_logger = "0.5" | ||
tokio = { version = "1", features = ["sync"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../LICENSE-APACHE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../LICENSE-MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Actix WS (Next Gen) | ||
|
||
> WebSockets for Actix Web, without actors. | ||
[![crates.io](https://img.shields.io/crates/v/actix-ws?label=latest)](https://crates.io/crates/actix-ws) | ||
[![Documentation](https://docs.rs/actix-ws/badge.svg?version=0.2.0)](https://docs.rs/actix-ws/0.2.0) | ||
![Apache 2.0 or MIT licensed](https://img.shields.io/crates/l/actix-ws) | ||
[![Dependency Status](https://deps.rs/crate/actix-ws/0.2.0/status.svg)](https://deps.rs/crate/actix-ws/0.2.0) | ||
|
||
## Documentation & Resources | ||
|
||
- [API Documentation](https://docs.rs/actix-ws) | ||
- [Example Projects](https://github.com/actix/examples/tree/master/websockets) | ||
- Minimum Supported Rust Version (MSRV): 1.68 | ||
|
||
## Usage | ||
|
||
```toml | ||
# Cargo.toml | ||
anyhow = "1" | ||
actix-web = "4" | ||
actix-ws-ng = "0.3" | ||
``` | ||
|
||
```rust | ||
// main.rs | ||
use actix_web::{middleware::Logger, web, App, Error, HttpRequest, HttpResponse, HttpServer}; | ||
use actix_ws::Message; | ||
|
||
async fn ws(req: HttpRequest, body: web::Payload) -> Result<HttpResponse, Error> { | ||
let (response, mut session, mut msg_stream) = actix_ws::handle(&req, body)?; | ||
|
||
actix_rt::spawn(async move { | ||
while let Some(Ok(msg)) = msg_stream.next().await { | ||
match msg { | ||
Message::Ping(bytes) => { | ||
if session.pong(&bytes).await.is_err() { | ||
return; | ||
} | ||
} | ||
Message::Text(s) => println!("Got text, {}", s), | ||
_ => break, | ||
} | ||
} | ||
|
||
let _ = session.close(None).await; | ||
}); | ||
|
||
Ok(response) | ||
} | ||
|
||
#[actix_web::main] | ||
async fn main() -> Result<(), anyhow::Error> { | ||
HttpServer::new(move || { | ||
App::new() | ||
.wrap(Logger::default()) | ||
.route("/ws", web::get().to(ws)) | ||
}) | ||
.bind("127.0.0.1:8080")? | ||
.run() | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under either of | ||
|
||
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) | ||
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) | ||
|
||
at your option. |
Oops, something went wrong.