Module api

Module api 

Source
Expand description

§Core HTTP API

This module provides the main HTTP API for the Guts node, including:

  • Git Smart HTTP Protocol: Standard Git endpoints for clone, push, and pull
  • Repository Management: CRUD operations for repositories
  • Health Checks: Comprehensive liveness, readiness, and startup probes
  • Metrics: Prometheus metrics endpoint

§Endpoint Overview

MethodPathDescription
GET/healthOverall health status
GET/health/liveLiveness probe
GET/health/readyReadiness probe
GET/health/startupStartup probe
GET/metricsPrometheus metrics
GET/api/reposList all repositories
POST/api/reposCreate a new repository
GET/api/repos/{owner}/{name}Get repository details
GET/git/{owner}/{name}/info/refsGit reference advertisement
POST/git/{owner}/{name}/git-upload-packGit fetch/clone
POST/git/{owner}/{name}/git-receive-packGit push

§Git Smart HTTP Protocol

The node implements Git’s Smart HTTP protocol, enabling standard Git clients to interact with repositories:

# Clone a repository
git clone http://localhost:8080/git/alice/myrepo

# Push changes
git push origin main

# Fetch updates
git fetch origin

§Application State

All handlers share an AppState containing:

  • repos: Repository storage (Git objects and refs)
  • collaboration: Pull requests, issues, comments storage
  • auth: Organizations, teams, permissions storage
  • p2p: Optional P2P manager for network replication
  • realtime: Event hub for WebSocket real-time updates

§Error Handling

Errors are returned as JSON with appropriate HTTP status codes:

{
  "error": "repository not found: alice/myrepo"
}
StatusMeaning
404Repository not found
409Repository already exists
422Validation error
500Internal server error

Structs§

AppState
Application state shared across handlers.
CreateRepoRequest
Request to create a repository.
RepoInfo
Repository info for listing.
RepoStore
Re-export RepoStore for external use. Global repository store.

Enums§

ApiError
API error type.

Functions§

create_router
Creates the API router with health state.