9 releases (breaking)

new 0.7.0 Nov 30, 2024
0.6.0 Jul 5, 2024
0.5.2 Apr 23, 2024
0.5.1 Feb 28, 2024
0.1.0 Aug 28, 2023

#363 in Game dev

Download history 9/week @ 2024-08-16 3/week @ 2024-08-30 9/week @ 2024-09-06 10/week @ 2024-09-13 33/week @ 2024-09-20 37/week @ 2024-09-27 16/week @ 2024-10-04 28/week @ 2024-10-11 5/week @ 2024-10-18 12/week @ 2024-10-25 33/week @ 2024-11-01 15/week @ 2024-11-08 23/week @ 2024-11-15 21/week @ 2024-11-22 132/week @ 2024-11-29

199 downloads per month

MIT/Apache

44KB
392 lines

bevy_http_client

Crates.io Downloads Documentation MIT/Apache 2.0

A simple HTTP client Bevy Plugin for both native and WASM.

Example

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)
        .add_systems(
            Update,
            send_request.run_if(on_timer(std::time::Duration::from_secs(1))),
        );
    app.register_request_type::<IpInfo>();
    app.run();
}

fn send_request(mut ev_request: EventWriter<TypedRequest<IpInfo>>) {
    ev_request.send(
        HttpClient::new()
            .get("https://api.ipify.org?format=json")
            .with_type::<IpInfo>(),
    );
}

fn handle_response(mut ev_response: EventReader<TypedResponse<IpInfo>>) {
    for response in ev_response.read() {
        println!("ip: {}", response.ip);
    }
}

Supported Versions

bevy bevy_http_client
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:

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 dual licensed as above, without any additional terms or conditions.

Dependencies

~11–21MB
~285K SLoC