官方套件 · 框架

Axum 與 Actix Web 的即時、等候室與聊天

Hibira crate 可發送事件、簽署頻道訂閱與驗證 webhook、在 Axum 或 Actix Web 路由前加上等候室,並呼叫 Chat API 與 Approvals。

crates.io 版本授權條款

最快的方式:裝好 Hibira 外掛,貼上一段提示詞

在你的 AI 程式助手裝好外掛,再貼上提示詞。助手會幫你登入、需要時建立免費應用、寫好程式碼並送出測試事件。 GitHub ↗

  1. 安裝外掛

    claude plugin marketplace add hibira-io/agent-plugin
    claude plugin install hibira@hibira
  2. 貼上這段提示詞

    Add Hibira Rust (hibira) to this project.
    Follow https://hibira.io/guides/rust, adapted to how this project is already set up.
    If I have no Hibira app yet, create a Free one that allows http://localhost so I can test right away.
    Keep the app key and secret in environment variables, add placeholders to .env.example, and never commit real values or send the secret to a browser.
    When you are done, send a test event, show me it arriving, and list the files you changed.

想自己動手? 下方的步驟如下:

  1. 安裝
  2. 設定
  3. 使用

其他 AI 工具與外掛內容 →

  • 提供 Axum 與 Actix Web 的等候室 middleware;handler 會收到訪客的 pass。
  • 私有與 presence 頻道授權、pusher-js 登入與 webhook 驗證;關閉 client feature 時不含任何網路程式碼。
  • 同一個 crate 也提供 Chat API、Approvals 與 Live Chat 驗證訪客。

登入後,範例程式碼會自動帶入您的叢集主機。 登入

  1. 安裝

    cargo add hibira --features axum   # or --features actix
  2. 設定

    HIBIRA_APP_ID=YOUR_APP_ID
    HIBIRA_KEY=YOUR_APP_KEY
    HIBIRA_SECRET=YOUR_APP_SECRET
    HIBIRA_HOST=ws.hibira.io
  3. 使用

    use std::sync::Arc;
    use axum::{middleware, routing::get, Extension, Router};
    use hibira::{waiting_room::axum_guard, Client, Config, Pass};
    
    let config = Config::from_env()?;
    let hibira = Client::new(config.clone());
    hibira.trigger(&["orders"], "order.shipped", &serde_json::json!({ "id": 1042 })).await?;
    
    let app = Router::new()
        .route("/drop", get(|Extension(pass): Extension<Pass>| async move { format!("You are number {}", pass.number) }))
        .layer(middleware::from_fn_with_state(Arc::new(config.waiting_room("presale")), axum_guard));

開始之前

  • 應用程式的密鑰只會在建立應用程式或輪替密鑰時顯示一次。請只放在伺服器上,不要放進瀏覽器或遊戲的建置檔。
  • 私人頻道與 presence 頻道需要後端提供授權端點,用應用程式密鑰簽署訂閱,做法和 pusher-js 相同。

請使用儀表板中的應用程式 Key;Secret 只放在你的伺服器上。頻道、事件與授權端點的用法和 Pusher 完全相同。 免費建立帳號 →