solid_pod_rs_git/lib.rs
1//! # solid-pod-rs-git
2//!
3//! Git HTTP smart-protocol backend for
4//! [`solid-pod-rs`](https://crates.io/crates/solid-pod-rs).
5//!
6//! ## Modules
7//!
8//! - [`service`] — Framework-agnostic [`GitHttpService`] that speaks `git-http-backend` CGI.
9//! - [`auth`] — `Basic nostr:<token>` and NIP-98 bearer auth extractors.
10//! - [`guard`] — Path-traversal rejection and repo-slug extraction.
11//! - [`config`] — Git repository config helpers (`receive.denyCurrentBranch`, etc.).
12//! - [`error`] — [`GitError`] enum with HTTP status-code mapping.
13//!
14//! ## Quick start
15//!
16//! ```no_run
17//! use std::path::PathBuf;
18//! use solid_pod_rs_git::{GitHttpService, BasicNostrExtractor};
19//!
20//! # async fn run() {
21//! // Create the service rooted at a pod's data directory.
22//! let service = GitHttpService::new(PathBuf::from("/var/pods/alice"))
23//! .with_auth(BasicNostrExtractor::new());
24//!
25//! // In your HTTP router, translate framework types to GitRequest and call:
26//! // let response = service.handle(git_request).await;
27//! # }
28//! ```
29//!
30//! ## Feature flags
31//!
32//! | Flag | Purpose |
33//! |-------------------|-------------------------------------------------|
34//! | `with-git-binary` | Enable integration tests that need the `git` CLI and `git-http-backend` CGI binary. Unit tests always run. |
35//!
36//! ## Architecture
37//!
38//! The crate is framework-agnostic: [`GitHttpService`] consumes a
39//! [`GitRequest`] and produces a [`GitResponse`]. The embedding HTTP
40//! server (axum, actix-web, hyper, ...) translates between its native
41//! types and these. Internally the service spawns `git http-backend`
42//! (path overridable via `GIT_HTTP_BACKEND_PATH`) and shuttles bytes.
43
44#![doc = include_str!("../README.md")]
45
46#![deny(unsafe_code)]
47#![warn(missing_docs)]
48#![warn(rust_2018_idioms)]
49
50pub mod auth;
51pub mod config;
52pub mod error;
53pub mod guard;
54pub mod service;
55
56pub use auth::{AuthError, BasicNostrExtractor, GitAuth};
57pub use config::{find_git_dir, GitDir};
58pub use error::GitError;
59pub use guard::{extract_repo_slug, path_safe};
60pub use service::{GitHttpService, GitRequest, GitResponse, DEFAULT_GIT_HTTP_BACKEND};