pub struct WebhookClient { /* private fields */ }Expand description
Webhook 客户端。
Implementations§
Source§impl WebhookClient
impl WebhookClient
Sourcepub fn with_client(client: Client) -> Self
pub fn with_client(client: Client) -> Self
使用自定义 HTTP 客户端创建 Webhook 客户端
允许配置连接池、超时等参数:
use openlark_webhook::prelude::*;
let http_client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(30))
.pool_max_idle_per_host(10)
.build()
.expect("Failed to build HTTP client");
let client = WebhookClient::with_client(http_client);Sourcepub fn with_secret(self, secret: String) -> Self
pub fn with_secret(self, secret: String) -> Self
设置签名密钥(启用签名验证)
Sourcepub async fn send(
&self,
webhook_url: &str,
payload: Value,
) -> Result<SendWebhookMessageResponse>
pub async fn send( &self, webhook_url: &str, payload: Value, ) -> Result<SendWebhookMessageResponse>
发送原始 JSON 负载到指定 webhook。
payload 需要符合飞书自定义机器人消息协议。
Sourcepub async fn send_text(
&self,
webhook_url: &str,
text: String,
) -> Result<SendWebhookMessageResponse>
pub async fn send_text( &self, webhook_url: &str, text: String, ) -> Result<SendWebhookMessageResponse>
发送文本消息。
Sourcepub async fn send_post(
&self,
webhook_url: &str,
post: String,
) -> Result<SendWebhookMessageResponse>
pub async fn send_post( &self, webhook_url: &str, post: String, ) -> Result<SendWebhookMessageResponse>
发送富文本消息。
Sourcepub async fn send_image(
&self,
webhook_url: &str,
image_key: String,
) -> Result<SendWebhookMessageResponse>
pub async fn send_image( &self, webhook_url: &str, image_key: String, ) -> Result<SendWebhookMessageResponse>
发送图片消息。
Trait Implementations§
Source§impl Clone for WebhookClient
impl Clone for WebhookClient
Source§fn clone(&self) -> WebhookClient
fn clone(&self) -> WebhookClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WebhookClient
impl Debug for WebhookClient
Auto Trait Implementations§
impl Freeze for WebhookClient
impl !RefUnwindSafe for WebhookClient
impl Send for WebhookClient
impl Sync for WebhookClient
impl Unpin for WebhookClient
impl UnsafeUnpin for WebhookClient
impl !UnwindSafe for WebhookClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more