Björn Benouarets 896b28a4e1 feat(http): Add health check endpoint
Add /_/healthz endpoint that returns 200 OK for service health monitoring.
2025-11-14 17:43:41 +01:00
2025-11-14 17:43:41 +01:00

GitHub Download Proxy

A Go-based proxy service that automatically reads repositories and formats paths based on a customizable URL template. Features flexible URL configuration through environment variables.

Features

  • Flexible URL template configuration via environment variables
  • Automatic path parsing and repository name extraction
  • Proper HTTP header forwarding and status code handling
  • Comprehensive logging with masterlog
  • Simple and clean implementation

Configuration

The proxy is configured via environment variables:

Variable Default Description
URL https://git.secnex.io/secnex/%s/raw/branch/main/bin/%s URL template with %s placeholders for repository and file path
PORT :8080 Port to listen on

The URL template uses two %s placeholders:

  1. First %s - Repository name
  2. Second %s - File path within the repository

Usage

Starting the server

# Default configuration (SecNex bin directory)
go run ./app

# With custom port
PORT=:9090 go run ./app

# For GitHub repositories
URL="https://github.com/%s/refs/heads/main/%s" go run ./app

# For SecNex raw files (not bin directory)
URL="https://git.secnex.io/secnex/%s/raw/branch/main/%s" go run ./app

# Custom Git server
URL="https://custom.git.server.com/%s/raw/main/%s" go run ./app

Making requests

Request format: GET /{repository}/{path/to/file}

# Get specific file
curl http://localhost:8080/my-repo/path/to/file.txt

# Get file from repository root
curl http://localhost:8080/my-repo/config.yaml

Examples

SecNex Bin Directory (Default)

# Default configuration
go run ./app

# Request file
curl http://localhost:8080/my-app/release/my-app-linux

This proxies to: https://git.secnex.io/secnex/my-app/raw/branch/main/bin/release/my-app-linux

GitHub Raw Files

# Configure for GitHub
URL="https://github.com/%s/refs/heads/main/%s" go run ./app

# Request file
curl http://localhost:8080/octocat/Hello-World/README.md

This proxies to: https://github.com/octocat/Hello-World/refs/heads/main/README.md

Custom GitLab Instance

# Configure for custom GitLab
URL="https://gitlab.company.com/%s/-/raw/main/%s" go run ./app

# Request file
curl http://localhost:8080/project/repo/src/main.go

This proxies to: https://gitlab.company.com/project/repo/-/raw/main/src/main.go

Different Branch

# Configure for develop branch
URL="https://git.secnex.io/secnex/%s/raw/branch/develop/%s" go run ./app

Project Structure

.
├── app/
│   └── main.go          # Main application entry point
├── README.md            # This documentation
├── CLAUDE.md           # Development instructions
├── go.mod              # Go module definition
├── go.sum              # Dependency checksums
├── Dockerfile          # Container configuration
└── docker-compose.yml  # Development setup

Building

# Build the application
go build ./app

# Build for production
go build -o gh-download-proxy ./app

# Run tests
go test ./...

Dependencies

  • Go 1.25.3+
  • git.secnex.io/secnex/masterlog v0.1.0

Running with Docker

# Build the Docker image
docker build -t gh-download-proxy .

# Run with default configuration
docker run -p 8080:8080 gh-download-proxy

# Run with custom URL
docker run -p 8080:8080 -e URL="https://github.com/%s/refs/heads/main/%s" gh-download-proxy
Description
No description provided
Readme 35 KiB
Languages
Go 93.3%
Dockerfile 6.7%