aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-core
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-22 15:23:52 +0900
committernsfisis <nsfisis@gmail.com>2026-02-22 15:23:52 +0900
commit7f75c394502d32a9a8967dcf3602141098fdd07d (patch)
treea608e90009d5664933fc5bba3cd08a5c7d2e5a48 /crates/mozart-core
parent0a6bafc75f329910bcaeb7d83feee3f9b01db66b (diff)
downloadphp-mozart-7f75c394502d32a9a8967dcf3602141098fdd07d.tar.gz
php-mozart-7f75c394502d32a9a8967dcf3602141098fdd07d.tar.zst
php-mozart-7f75c394502d32a9a8967dcf3602141098fdd07d.zip
refactor(http): centralize User-Agent string in mozart-core
Add mozart_core::http::user_agent() that returns a consistent "Mozart/<version> (<os>; <arch>)" string. Replace all scattered user-agent definitions across mozart-registry and mozart CLI commands. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-core')
-rw-r--r--crates/mozart-core/src/http.rs11
-rw-r--r--crates/mozart-core/src/lib.rs1
2 files changed, 12 insertions, 0 deletions
diff --git a/crates/mozart-core/src/http.rs b/crates/mozart-core/src/http.rs
new file mode 100644
index 0000000..ebd28f9
--- /dev/null
+++ b/crates/mozart-core/src/http.rs
@@ -0,0 +1,11 @@
+/// Returns the common User-Agent string for all HTTP requests.
+///
+/// Format: `Mozart/<version> (<os>; <arch>)`
+pub fn user_agent() -> String {
+ format!(
+ "Mozart/{} ({}; {})",
+ env!("CARGO_PKG_VERSION"),
+ std::env::consts::OS,
+ std::env::consts::ARCH,
+ )
+}
diff --git a/crates/mozart-core/src/lib.rs b/crates/mozart-core/src/lib.rs
index b02e5a3..aef7af3 100644
--- a/crates/mozart-core/src/lib.rs
+++ b/crates/mozart-core/src/lib.rs
@@ -1,5 +1,6 @@
pub mod console;
pub mod exit_code;
+pub mod http;
pub mod package;
pub mod platform;
pub mod suggest;