http

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package http implements an HTTP-based approver client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Label is a human-friendly name.
	Label string
	// URL is the approver endpoint.
	URL string
	// Method overrides HTTP method.
	Method string
	// Headers adds HTTP headers.
	Headers map[string]string
	// Timeout is the HTTP timeout.
	Timeout time.Duration
	// Async enables webhook-based async approvals.
	Async bool
	// WebhookURL is the yaml-mcp-server callback URL.
	WebhookURL string
	// Lang defines the preferred language for approver messages.
	Lang string
	// Markup selects approval message markup (markdown/html).
	Markup string
	// Pending stores async approvals.
	Pending *PendingStore
}

Client calls external HTTP approvers.

func (Client) Approve

func (c Client) Approve(ctx context.Context, req approver.Request) (approver.Decision, error)

Approve sends a request to the HTTP approver and parses the decision.

func (Client) Name

func (c Client) Name() string

Name returns approver name for audit and logging.

type PendingStore added in v1.1.0

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

PendingStore keeps async approval results.

func NewPendingStore added in v1.1.0

func NewPendingStore() *PendingStore

NewPendingStore creates a new async approval store.

func (*PendingStore) Cancel added in v1.1.0

func (s *PendingStore) Cancel(correlationID string)

Cancel removes a pending approval without a decision.

func (*PendingStore) Register added in v1.1.0

func (s *PendingStore) Register(correlationID, source string) (<-chan approver.Decision, error)

Register allocates a pending slot for correlationID.

func (*PendingStore) Resolve added in v1.1.0

func (s *PendingStore) Resolve(correlationID string, decision approver.Decision) bool

Resolve delivers a decision for correlationID.

type WebhookHandler added in v1.1.0

type WebhookHandler struct {
	Store  *PendingStore
	Logger *slog.Logger
}

WebhookHandler handles async approval callbacks.

func (*WebhookHandler) ServeHTTP added in v1.1.0

func (h *WebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP processes webhook callbacks from async approvers.

Jump to

Keyboard shortcuts

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