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#![deny(unsafe_code)]
46#![warn(missing_docs)]
47#![warn(rust_2018_idioms)]
48
49pub mod api;
50pub mod auth;
51pub mod config;
52pub mod error;
53pub mod guard;
54pub mod init;
55pub mod service;
56
57pub use api::{
58 git_add, git_branches, git_commit, git_create_branch, git_diff, git_discard, git_log,
59 git_status, git_unstage, BranchInfo, ChangeType, CommitEntry, CommitResult, FileStatus,
60 StatusReport,
61};
62pub use auth::{AuthError, BasicNostrExtractor, GitAuth};
63pub use config::{find_git_dir, GitDir};
64pub use error::GitError;
65pub use guard::{extract_repo_slug, path_safe};
66pub use init::GitAutoInit;
67pub use service::{GitHttpService, GitRequest, GitResponse, DEFAULT_GIT_HTTP_BACKEND};