Help us shape the future of Go! Take the 2026 Go Developer Survey

httpapi

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, addr string, handler http.Handler) error

Types

type AccessConfig added in v0.2.1

type AccessConfig struct {
	TeamDomain string
	Audience   string
	HTTPClient *http.Client
	Now        func() time.Time
}

type AccessLogMode added in v0.5.0

type AccessLogMode string

AccessLogMode selects how much of the per-request access log the server writes. The zero value logs every request, which is what operators got before the mode existed.

const (
	AccessLogAll    AccessLogMode = "all"
	AccessLogErrors AccessLogMode = "errors"
	AccessLogOff    AccessLogMode = "off"
)

type GitHubOAuthConfig

type GitHubOAuthConfig struct {
	ClientID      string
	ClientSecret  string
	PublicURL     string
	AuthURL       string
	TokenURL      string
	UserURL       string
	EmailsURL     string
	MembershipURL string
	AllowedOrg    string
	ModeratorOrg  string
	HTTPClient    *http.Client
}

type HomeLinkConfig added in v0.4.0

type HomeLinkConfig struct {
	URL   string `json:"url"`
	Label string `json:"label"`
}

HomeLinkConfig points the workspace rail's home button somewhere other than the ClickClack landing page, for deployments that live inside a larger product. Values are validated by config.Config.ValidateServe before New; empty fields keep the built-in destination and label.

type OpenClawIDConfig added in v0.4.0

type OpenClawIDConfig struct {
	ClientID     string
	ClientSecret string
	Issuer       string
	PublicURL    string
	AuthURL      string
	TokenURL     string
	HTTPClient   *http.Client
}

OpenClawIDConfig configures browser sign-in through the first-party OpenClaw ID OIDC provider (Better Auth OAuth 2.1 at id.openclaw.ai).

func (OpenClawIDConfig) ApplyDiscovery added in v0.6.0

func (c OpenClawIDConfig) ApplyDiscovery(ctx context.Context) (OpenClawIDConfig, error)

ApplyDiscovery fills unset endpoints from issuer metadata, preserving each explicit override. Only the default OpenClaw ID issuer can fall back when discovery is unavailable; malformed metadata always fails closed.

type Options

type Options struct {
	UploadDir           string
	UploadStorage       uploadstore.Store
	GitHubOAuth         GitHubOAuthConfig
	OpenClawID          OpenClawIDConfig
	Access              AccessConfig
	FrontendURL         string
	PublicAPIURL        string
	HomeLink            HomeLinkConfig
	EmbedFrameAncestors []string
	CookieNames         authpolicy.CookieNames
	DisableDevAuth      bool
	PasswordAuthEnabled bool
	PushNotifier        PushNotifier
	WebPushNotifier     PushNotifier
	WebPushPublicKey    string
	MetricsEnabled      bool
	AccessLog           AccessLogMode
	Environment         string
	Version             string
	Commit              string
	// contains filtered or unexported fields
}

type PushNotification

type PushNotification struct {
	RecipientKey  string
	Title         string
	Message       string
	UserID        string
	MessageID     string
	Tag           string
	URL           string
	Subscriptions []store.PushSubscriptionTarget
}

PushNotification is one alert for one recipient. Pushover reads the recipient key, the title, and the message. The web push notifier reads the title and the rest and ignores the key; it is handed no message, because it reads the text from the stored message when the push is sent.

type PushNotifier

type PushNotifier interface {
	Notify(ctx context.Context, notification PushNotification) error
}

type PushoverNotifier

type PushoverNotifier struct {
	Token  string
	Client *http.Client
}

func NewPushoverNotifier

func NewPushoverNotifier(token string) *PushoverNotifier

func (*PushoverNotifier) Notify

func (p *PushoverNotifier) Notify(ctx context.Context, notification PushNotification) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(st store.Store, hub *realtime.Hub, options Options) *Server

func (*Server) CleanupPendingUploadObjects added in v0.2.0

func (s *Server) CleanupPendingUploadObjects(ctx context.Context, limit int) error

func (*Server) Handler

func (s *Server) Handler() http.Handler

type WebPushConfig added in v0.6.0

type WebPushConfig struct {
	VAPIDPublicKey  string
	VAPIDPrivateKey string
	Subject         string
}

WebPushConfig is the application server identity used for every push.

type WebPushNotifier added in v0.6.0

type WebPushNotifier struct {
	// contains filtered or unexported fields
}

WebPushNotifier delivers notifications to browser push services from a bounded worker pool, off the request path, and sweeps the devices that can no longer receive.

func NewWebPushNotifier added in v0.6.0

func NewWebPushNotifier(config WebPushConfig, subscriptions WebPushSubscriptionStore) *WebPushNotifier

NewWebPushNotifier builds a notifier that sends through the same outbound policy as callbacks: no proxy, no redirects, and no destination inside the deployment's own network.

func (*WebPushNotifier) Close added in v0.6.0

func (n *WebPushNotifier) Close()

Close stops new deliveries and gives the worker pool a bounded drain.

func (*WebPushNotifier) Notify added in v0.6.0

func (n *WebPushNotifier) Notify(_ context.Context, notification PushNotification) error

Notify queues deliveries without waiting for push services.

type WebPushSubscriptionStore added in v0.6.0

type WebPushSubscriptionStore interface {
	GetPushSubscriptionDelivery(ctx context.Context, userID, endpoint, currentKeyID string) (store.PushSubscriptionTarget, error)
	GetMessage(ctx context.Context, messageID, userID string) (store.Message, error)
	GetChannelNotificationPreference(ctx context.Context, channelID, userID string) (string, error)
	ListMentionedUserIDs(ctx context.Context, workspaceID, body string) ([]string, error)
	DeletePushSubscription(ctx context.Context, userID, endpoint string) error
	MarkPushSubscriptionSuccess(ctx context.Context, userID, endpoint string) error
	MarkPushSubscriptionFailure(ctx context.Context, userID, endpoint string, retryAfter time.Duration) (int64, error)
	PrunePushSubscriptions(ctx context.Context, currentKeyID string, now time.Time) (store.PushPruneResult, error)
}

WebPushSubscriptionStore is the store contract used by delivery workers.

Jump to

Keyboard shortcuts

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