This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is bevy_http_client, a Bevy plugin that provides HTTP client capabilities for both native and WASM platforms.
It's a Rust crate that integrates with the Bevy game engine using the ECS (Entity Component System) architecture.
cargo test# Format code
cargo fmt --all
# Check formatting
cargo fmt --all -- --check
# Run clippy linting
cargo clippy -- -D warnings# Build the library
cargo build
# Build with release optimizations
cargo build --releaseExamples are located in the examples/ directory:
# Run specific examples
cargo run --example ipinfo
cargo run --example typed
cargo run --example observer
cargo run --example window- HttpClientPlugin: Main plugin that sets up the HTTP client system
- HttpClient: Builder pattern for creating HTTP requests with support for GET, POST, PUT, PATCH, DELETE, HEAD methods
- TypedRequest/TypedResponse: Generic typed wrapper for strongly-typed JSON deserialization
- HttpClientSetting: Resource for configuring concurrent request limits (default: 5)
- handle_request: Processes HTTP requests asynchronously using Bevy's IoTaskPool
- handle_tasks: Manages completion of async HTTP tasks and updates ECS world
- handle_typed_request: Handles typed requests with automatic JSON deserialization
The plugin uses Bevy's event system:
HttpRequest/HttpResponse/HttpResponseErrorfor untyped requestsTypedRequest<T>/TypedResponse<T>/TypedResponseError<T>for typed requests
- Native: Uses
ehttpwith async support - WASM: Full WASM compatibility with fetch API
// Basic HTTP request
let request = HttpClient::new()
.get("https://api.example.com")
.headers(& [("Content-Type", "application/json")])
.build();
// Typed HTTP request
let typed_request = HttpClient::new()
.get("https://api.example.com")
.with_type::<MyResponseType>();app.register_request_type::<MyType>();- Events are triggered both globally and on specific entities
- Supports entity-specific request tracking via
from_entity - Automatic entity cleanup for orphaned requests
src/lib.rs: Main plugin and core HTTP client implementationsrc/typed.rs: Typed request/response systemsrc/prelude.rs: Public API exportsexamples/: Usage examples demonstrating different features
- Bevy 0.16.0 (latest supported version)
- ehttp for HTTP functionality
- serde/serde_json for JSON serialization
- crossbeam-channel for async communication
- Claude.md 和 生成的报告不在git里提交
- 如果要删除原有的函数、方法, 先不删除, 先打上 deprecated 标签
- 和我交互使用中文.
- git 注释, 代码注释, README, CHANGELOG 使用英文