apicontract

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package apicontract defines the release-independent Tapper REST contract.

Index

Constants

View Source
const ClientHeader = "Tapper-Client-Version"
View Source
const DiscoveryInvalid = "API_DISCOVERY_INVALID"
View Source
const DiscoveryUnavailable = "API_DISCOVERY_UNAVAILABLE"
View Source
const Required = "API_VERSION_REQUIRED"
View Source
const Revision = "2026-09-11"
View Source
const Unsupported = "API_VERSION_UNSUPPORTED"
View Source
const VersionHeader = "Tapper-API-Version"

Variables

This section is empty.

Functions

func Do

func Do(client *http.Client, req *http.Request) (*http.Response, error)

Do applies discovery, mandatory headers, redirect restrictions and typed errors to a REST request. Non-REST OAuth and archive requests pass through unchanged.

func IsCompatibility

func IsCompatibility(err error) bool

func LogFailure

func LogFailure(ctx context.Context, logger *slog.Logger, level slog.Level, client string, err error, requestID string)

LogFailure emits only compatibility metadata, never request contents or credentials.

func Middleware

func Middleware(server string, logger *slog.Logger) func(http.Handler) http.Handler

Middleware gates all /api/v1 paths, including unknown operations, before auth. Discovery is build-only and remains usable when database services are down.

func WithSession

func WithSession(ctx context.Context, s *Session) context.Context

Types

type CompatibilityError

type CompatibilityError struct {
	Message            string   `json:"error"`
	Code               string   `json:"code"`
	Requested          []string `json:"requested_api_versions"`
	Supported          []string `json:"supported_api_versions"`
	ServerVersion      string   `json:"server_version,omitempty"`
	OperationPerformed bool     `json:"operationPerformed"`
}

CompatibilityError guarantees the blocked application operation was not sent or was rejected by the server before authentication and dispatch.

func Validate

func Validate(h http.Header, server string) *CompatibilityError

Validate accepts exactly one unmodified contract revision header value.

func (*CompatibilityError) Error

func (e *CompatibilityError) Error() string

type Discovery

type Discovery struct {
	ServerVersion string   `json:"server_version"`
	APIVersions   []string `json:"api_versions"`
}

type Session

type Session struct {
	ClientVersion string
	Logger        *slog.Logger
	// contains filtered or unexported fields
}

Session caches discovery per Hub for one invocation or MCP connection.

func FromContext

func FromContext(ctx context.Context) *Session

func NewSession

func NewSession(client string, logger *slog.Logger) *Session

func (*Session) Check

func (s *Session) Check(ctx context.Context, client *http.Client, base string) error

Check performs credential-free discovery once, bounded by the caller and five seconds.

Jump to

Keyboard shortcuts

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