Documentation
¶
Overview ¶
Package server wires up the HTTP server with all routes.
Package server wires together all ghp components and runs the HTTP server(s). It is responsible for:
- Opening the database and running/checking migrations
- Initializing encryption, token services, and the GitHub App provider
- Building the host-dispatch handler that routes requests by Host header to the appropriate backend (API proxy, github.com passthrough, codeload.github.com redirect/passthrough, Copilot passthrough, or management UI)
- Starting TLS and/or plain HTTP listeners (including systemd socket activation support)
- Running the dedicated Prometheus metrics server on a separate port
- Handling graceful shutdown (SIGINT/SIGTERM) and configuration hot-reload (SIGUSR1)
- Applying cross-cutting middleware: access logging, security headers, and the Server response header
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API handles the service API endpoints (token management, users).
func NewAPI ¶
func NewAPI(ctx context.Context, cfg *config.Config, store database.Store, ts *token.Service, ah *auth.Handler, enc *crypto.Encryptor, atp *ghpgithub.AppTokenProvider, ar *ghpgithub.AppRegistry, ptr *proxy.ProxyTokenResolver, ur *proxy.UsernameResolver, logger *slog.Logger, aw *auditLogWriter) *API
NewAPI creates a new API handler.
func (*API) RegisterRoutes ¶
RegisterRoutes adds API routes to the given mux. All routes require authentication via the auth handler.
func (*API) SetForwardProxyRouter ¶
func (a *API) SetForwardProxyRouter(fr *proxy.ForwardProxyRouter)
SetForwardProxyRouter wires the forward proxy router so ruleset mutations via the admin API rebuild the route table immediately.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main ghp server.
func New ¶
func New(cfg *config.Config, configPath string, version string, logger *slog.Logger, logProvider otellog.LoggerProvider, migrate bool) *Server
New creates a new Server. logProvider is the OpenTelemetry LoggerProvider used to emit the access and audit log streams; a nil provider falls back to a no-op provider so the server is safe to construct in tests.