handler

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

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 bundles shared HTTP handler dependencies.

func NewAPI

func NewAPI(
	authToken string,
	service CheckInService,
	registry *metrics.Registry,
	responseDetails bool,
	version, commit string,
	logger *slog.Logger,
) *API

NewAPI builds an API container with shared handler dependencies.

func (*API) CheckIn

func (a *API) CheckIn() http.HandlerFunc

CheckIn returns the check-in endpoint handler.

func (*API) Healthz

func (a *API) Healthz() http.HandlerFunc

Healthz returns a lightweight liveness endpoint.

func (*API) Metrics

func (a *API) Metrics() http.Handler

Metrics returns the Prometheus metrics endpoint handler.

func (*API) Readyz added in v0.0.11

func (a *API) Readyz() http.HandlerFunc

Readyz returns a lightweight readiness endpoint.

func (*API) SetNowFn

func (a *API) SetNowFn(nowFn func() time.Time)

SetNowFn replaces the API clock, primarily for tests.

func (*API) Status

func (a *API) Status() http.HandlerFunc

Status returns the current check-in monitor status endpoint handler.

func (*API) Version

func (a *API) Version() http.HandlerFunc

Version returns the running build version and commit.

type CheckInService

type CheckInService interface {
	RecordCheckIn(ctx context.Context, at time.Time) service.RecordCheckInResult
	Snapshot() service.SnapshotResult
}

CheckInService exposes the application behavior used by HTTP handler.

type RequestMetadata

type RequestMetadata struct {
	Remote          string
	ClientIP        string
	Method          string
	Path            string
	Host            string
	Proto           string
	UserAgent       string
	RequestID       string
	XForwardedFor   string
	XForwardedProto string
	XForwardedHost  string
	XRealIP         string
	Forwarded       string
}

RequestMetadata describes the request origin used for diagnostic logs.

Remote is the direct TCP peer that connected to this service. ClientIP is a best-effort value from proxy headers first, then from Remote. Do not use it for auth decisions unless your proxy chain sanitizes these headers.

func (RequestMetadata) LogFields

func (m RequestMetadata) LogFields() []any

LogFields returns structured request-origin fields for logs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL