Files
tiny-forge/internal/proxy/provider.go
alexei.dolgolyov 8d2c5a063b feat: static sites feature with Gitea/GitHub/GitLab support and Deno backend
Deploy static content from Git repository folders with optional server-side
API endpoints. Supports Gitea/Forgejo/Gogs, GitHub, and GitLab with provider
autodetection.

- New Sites entity with CRUD, encrypted secrets, and manual/push/tag sync triggers
- Pluggable GitProvider interface with three implementations
- Deno container mode: auto-generates router from API_{method}_{name} exports
- Static container mode: nginx serving files with optional markdown rendering
- Wizard UI with provider selector, repo picker, branch/folder tree pickers
- Deploy pipeline builds fresh image, starts container, configures NPM proxy
- Stop/Start buttons, force redeploy on manual trigger
- Periodic health checker detects crashed containers
- Proxy route existence check during auto-sync
2026-04-11 03:35:57 +03:00

42 lines
1.7 KiB
Go

package proxy
import "context"
// RouteOptions holds optional configuration for a proxy route.
type RouteOptions struct {
SSLCertificateID int
AccessListID int // NPM access list ID for authentication, 0 = public
ForwardScheme string // "http" or "https", defaults to "http"
}
// Provider is the interface for proxy route management.
// Implementations handle the specifics of each proxy system (NPM, Traefik, etc.).
// The "None" provider implements all methods as no-ops.
type Provider interface {
// Name returns the provider identifier (e.g., "npm", "traefik", "none").
Name() string
// ConfigureRoute creates or updates a proxy route for the given domain.
// Returns a route ID string that can be used for updates and deletes.
// For NPM, the route ID is the proxy host ID (stringified).
// For Traefik, the route ID is the router name.
// For None, returns empty string.
ConfigureRoute(ctx context.Context, domain, targetHost string, targetPort int, opts RouteOptions) (routeID string, err error)
// DeleteRoute removes a proxy route by its route ID.
// Does nothing if routeID is empty.
DeleteRoute(ctx context.Context, routeID string) error
// RouteExists returns true if a proxy route exists for the given domain.
// Used for health checks during auto-sync to detect externally removed routes.
RouteExists(ctx context.Context, domain string) (bool, error)
// ContainerLabels returns Docker labels to set on containers at creation time.
// Traefik uses labels for auto-discovery; NPM and None return nil.
ContainerLabels(domain string, port int) map[string]string
// Ping checks connectivity to the proxy backend.
// Returns nil if healthy or if the provider doesn't need external connectivity (None).
Ping(ctx context.Context) error
}