apidoc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package apidoc reads the Technitium API document vendored under api-defs: the calls it describes, by path, with the parameters each takes. Technitium publishes no machine-readable description of its API, only this document written for people, so this is what the client in sdk/technitium is held against - which calls exist, and what each is sent.

The document is regular enough to read: every call is a "###" section holding a "URL:" line with an example address, an optional "OBSOLETE PATH:" list, and a "WHERE:" list of parameters before its "RESPONSE:". A call that is sent a body says so under "REQUEST:", where a form's fields are shown as they are posted. A section that does not read that way is an error, never a call quietly left out: a document whose layout changed must not pass for one fully covered.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	// Title is the section's heading: List Zones
	Title string
	// Path is the call's path under /api/: zones/list
	Path string
	// Obsolete are the paths the call went by in older versions, which a
	// current client must not use
	Obsolete []string
	// Params are the names of the parameters the call takes: those its
	// WHERE list gives, those its example address carries, and the fields of
	// a form its REQUEST shows
	Params []string
	// Upload is the call taking a file, posted as a form's
	Upload bool
}

Call is one API call as the document describes it.

func (*Call) Takes

func (c *Call) Takes(param string) bool

Takes reports whether the call is documented as taking a parameter.

type Doc

type Doc struct {
	// Version is the server version the document is for, from its file name
	Version string
	// File is the document's file name
	File  string
	Calls []Call
}

Doc is the document read.

func Load

func Load(dir fs.FS) (*Doc, error)

Load reads the document in a directory for the highest server version there.

func Parse

func Parse(text string) (*Doc, error)

Parse reads the calls out of the document's text.

func Vendored

func Vendored() (*Doc, error)

Vendored reads the document vendored in this repository, for the highest server version there.

func (*Doc) Call

func (d *Doc) Call(path string) *Call

Call is the call at a path, nil when the document has none there.

func (*Doc) Paths

func (d *Doc) Paths() []string

Paths are every call's path, sorted.

func (*Doc) ReplacedBy

func (d *Doc) ReplacedBy(obsolete string) *Call

ReplacedBy is the call that now stands where an obsolete path did, nil when the path is no call's old one.

Jump to

Keyboard shortcuts

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