https://github.com/foxzool/bevy_http_client
A simple HTTP client Bevy Plugin for both native and WASM
https://github.com/foxzool/bevy_http_client
bevy http-client reqwest rest
Last synced: 12 months ago
JSON representation
A simple HTTP client Bevy Plugin for both native and WASM
- Host: GitHub
- URL: https://github.com/foxzool/bevy_http_client
- Owner: foxzool
- License: apache-2.0
- Created: 2023-08-27T09:48:19.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2025-06-03T05:09:45.000Z (about 1 year ago)
- Last Synced: 2025-06-12T01:04:41.913Z (12 months ago)
- Topics: bevy, http-client, reqwest, rest
- Language: Rust
- Homepage: https://foxzool.github.io/bevy_http_client/
- Size: 7.05 MB
- Stars: 32
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# bevy_http_client
[](https://github.com/foxzool/bevy_http_client/actions)
[](https://crates.io/crates/bevy_http_client)
[](https://crates.io/crates/bevy_http_client)
[](https://docs.rs/bevy_http_client)
[](https://github.com/Seldom-SE/seldom_pixel#license)
A simple HTTP client Bevy Plugin for both native and WASM.
## Example
```rust
use bevy::{prelude::*, time::common_conditions::on_timer};
use bevy_http_client::prelude::*;
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize, Default)]
pub struct IpInfo {
pub ip: String,
}
fn main() {
let mut app = App::new();
app.add_plugins((MinimalPlugins, HttpClientPlugin))
.add_systems(Update, (handle_response, handle_error))
.add_systems(
Update,
send_request.run_if(on_timer(std::time::Duration::from_secs(1))),
);
app.register_request_type::();
app.run();
}
fn send_request(mut ev_request: EventWriter>) {
ev_request.send(
HttpClient::new()
.get("https://api.ipify.org?format=json")
.with_type::(),
);
}
/// consume TypedResponse events
fn handle_response(mut events: ResMut>>) {
for response in events.drain() {
let response: IpInfo = response.into_inner();
println!("ip info: {:?}", response);
}
}
fn handle_error(mut ev_error: EventReader>) {
for error in ev_error.read() {
println!("Error retrieving IP: {}", error.err);
}
}
```
## Supported Versions
| bevy | bevy_http_client |
|------|------------------|
| 0.16 | 0.8 |
| 0.15 | 0.7 |
| 0.14 | 0.6 |
| 0.13 | 0.4, 0,5 |
| 0.12 | 0.3 |
| 0.11 | 0.1 |
## License
Dual-licensed under either:
- [`MIT`](LICENSE-MIT): [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)
- [`Apache 2.0`](LICENSE-APACHE): [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
At your option. This means that when using this crate in your game, you may choose which license to use.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as
defined in the Apache-2.0 license, shall be dually licensed as above, without any additional terms or conditions.