app

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("app",
	fx.Provide(provideConfig),
	fx.Provide(provideContext),
	fx.Invoke(attachSignalHandler),
)

Functions

func ContextWithSession

func ContextWithSession(ctx context.Context, session *Session) context.Context

ContextWithSession returns a context with session attached.

Types

type Config

type Config struct {
	// Transport mode: "http" or "stdio"
	Transport string

	// HTTP server settings (only used when Transport == "http")
	ListenAddr string

	// UptimeURL is the Uptime.com instance URL (e.g., https://uptime.com).
	// Used to derive both the API base URL (UptimeURL + "/api/v1/") and the
	// OAuth2 authorization server endpoints when APIURL / OAuthURL are unset.
	UptimeURL string

	// APIURL, when non-empty, is the full Uptime.com API base URL, used
	// verbatim instead of deriving it from UptimeURL. Useful in split-horizon
	// deployments where the API is reached over an internal address.
	APIURL string

	// OAuthURL, when non-empty, is the full OAuth2 authorization server base
	// (issuer), used verbatim instead of UptimeURL. Useful when the client-facing
	// authorization server differs from the internal API host.
	OAuthURL string

	// ResourceURL is this server's public URL for OAuth2 protected resource metadata.
	// Defaults to http://localhost{ListenAddr} when not set.
	ResourceURL string

	// ClientID is the OAuth2 client ID.
	ClientID string

	// ClientSecret is the OAuth2 client secret (confidential clients).
	ClientSecret string

	// LogLevel for application logger (debug, info, warn, error)
	LogLevel *slog.LevelVar
}

Config holds the application configuration from CLI flags.

func (Config) APIBaseURL

func (c Config) APIBaseURL() string

APIBaseURL returns the Uptime.com API base URL. When APIURL is set it is used verbatim; otherwise the base is derived from UptimeURL.

func (Config) OAuthIssuer added in v0.17.0

func (c Config) OAuthIssuer() string

OAuthIssuer returns the OAuth2 authorization server base (issuer). When OAuthURL is set it is used verbatim; otherwise it falls back to UptimeURL.

type Session

type Session struct {
	Token  string // OAuth2 bearer token
	Client upapi.API
}

Session holds per-session state including the authenticated Uptime client. Client is created once per session by middleware and cached.

func SessionFromContext

func SessionFromContext(ctx context.Context) *Session

SessionFromContext retrieves session from context.

Jump to

Keyboard shortcuts

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