Skip to main content

Crate harbor_sdk

Crate harbor_sdk 

Source
Expand description

harbor-sdk — Rust SDK for Harbor API monetization

Add API key auth and billing to your Rust API in one line. See harbor-black.vercel.app for docs.

§Quick Start (Axum)

use axum::{Router, routing::get, Extension};
use harbor_sdk::{HarborLayer, KeyInfo};

async fn data(Extension(key): Extension<KeyInfo>) -> String {
    format!("Plan: {}", key.plan)
}

#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/data", get(data))
        .layer(HarborLayer::new("proj_harbor_xyz"));
    axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
        .serve(app.into_make_service())
        .await
        .unwrap();
}

Structs§

HarborLayer
Tower middleware layer for easy integration.
KeyInfo
Validated API key metadata returned after successful validation.

Enums§

HarborError

Constants§

DEFAULT_VALIDATE_URL

Functions§

validate
Validate a Harbor API key asynchronously.
validate_with_url
Validate with a custom URL (for local dev emulator).