git-next/crates/config/src/webhook/message.rs
Paul Campbell 271f4ec1dc
All checks were successful
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Rust / build (push) Successful in 1m13s
tests: tidy up config, forgejo and git tests
Coverage for config, forge, forgejo and github is now 100%.
2024-06-06 17:45:33 +01:00

41 lines
947 B
Rust

//
use actix::prelude::*;
use crate as config;
use std::collections::HashMap;
#[derive(Message, Debug, Clone, derive_more::Constructor)]
#[rtype(result = "()")]
pub struct WebhookMessage {
forge_alias: config::ForgeAlias,
repo_alias: config::RepoAlias,
headers: HashMap<String, String>,
body: Body,
}
impl WebhookMessage {
pub const fn forge_alias(&self) -> &config::ForgeAlias {
&self.forge_alias
}
pub const fn repo_alias(&self) -> &config::RepoAlias {
&self.repo_alias
}
pub const fn body(&self) -> &Body {
&self.body
}
pub fn header(&self, header: &str) -> Option<String> {
self.headers.get(header).map(|value| value.to_string())
}
}
#[derive(Clone, Debug, derive_more::Constructor)]
pub struct Body(String);
impl Body {
pub fn as_str(&self) -> &str {
self.0.as_str()
}
pub fn as_bytes(&self) -> &[u8] {
self.0.as_bytes()
}
}