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

contract

package
v0.135.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package contract renders ContentKit's route catalog (internal/httpapi) and error-code registry as the files other tools read: api/openapi.json, the Go client's methods (client_gen.go), the browser SDK's generated route table, wire types and error codes, and docs/api/routes.md. They are committed: `go generate ./internal/contract` rewrites them and TestGeneratedContractIsFresh fails when one is stale.

Index

Constants

View Source
const (
	OpenAPIFile = "api/openapi.json"
	RoutesDoc   = "docs/api/routes.md"
	SDKDir      = "sdk/ui/src/client/generated/"
)

Where each generated file lives, relative to the repository.

View Source
const GoClientFile = "client_gen.go"

GoClientFile is the generated Go client: a method on contentkit.Client per route.

View Source
const GoErrorCodesFile = "error_codes_gen.go"

GoErrorCodesFile holds the error codes as Go constants.

Variables

This section is empty.

Functions

func Files

func Files(fsys fs.FS) (map[string][]byte, error)

Files renders every generated file by repository path. fsys is the repository: enum values are read from the source that declares them.

func Write

func Write(root string) error

Write renders every generated file into the repository at root.

Types

type ErrorReply

type ErrorReply struct {
	Error      string              `json:"error"`
	Code       string              `json:"code"`
	RetryAfter int                 `json:"retry_after,omitempty"`
	Action     content.Action      `json:"action,omitempty"`
	Ban        *content.BanNotice  `json:"ban,omitempty"`
	Blobs      []string            `json:"blobs,omitempty"`
	Details    *media.ErrorDetails `json:"details,omitempty"`
	// Reason and AvailableAt explain a download_unavailable: the host
	// policy's code and when the download opens.
	Reason      string     `json:"reason,omitempty"`
	AvailableAt *time.Time `json:"available_at,omitempty"`
}

ErrorReply is the flat error body every module answers. A code's own members appear only with it: retry_after with rate_limited and unavailable, action with an interaction's rate_limited, ban with comment_banned, blobs with not_uploaded, details with an upload refusal.

Directories

Path Synopsis
Command gen writes the files generated from the route catalog (go generate ./internal/contract).
Command gen writes the files generated from the route catalog (go generate ./internal/contract).

Jump to

Keyboard shortcuts

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