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§
- Harbor
Layer - Tower middleware layer for easy integration.
- KeyInfo
- Validated API key metadata returned after successful validation.
Enums§
Constants§
Functions§
- validate
- Validate a Harbor API key asynchronously.
- validate_
with_ url - Validate with a custom URL (for local dev emulator).