ietf

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ietf is the library behind the ietf command line: the HTTP client, request shaping, and the typed data models for the IETF Datatracker API (RFC documents and working groups).

The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public site throws under load.

Index

Constants

View Source
const BaseURL = "https://" + Host

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "ietf-cli/dev (+https://github.com/tamnd/ietf-cli)"

DefaultUserAgent identifies the client to the IETF Datatracker. A real, honest User-Agent is both polite and the thing most likely to keep you unblocked.

View Source
const Host = "datatracker.ietf.org"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	BaseURL   string
	// Rate is the minimum gap between requests. Zero means no pacing.
	Rate    time.Duration
	Retries int
	// contains filtered or unexported fields
}

Client talks to the IETF Datatracker over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with DefaultConfig values.

func (*Client) Get

func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)

Get fetches url and returns the response body. It paces and retries according to the client's settings.

func (*Client) GetRFC

func (c *Client) GetRFC(ctx context.Context, number string) (*RFC, error)

GetRFC fetches one RFC by number. The number may be "2616" or "rfc2616"; both are accepted.

func (*Client) ListWGs

func (c *Client) ListWGs(ctx context.Context, state string, limit int) ([]WorkingGroup, error)

ListWGs lists IETF working groups. state="" returns all; "active" filters to active groups.

func (*Client) SearchRFCs

func (c *Client) SearchRFCs(ctx context.Context, query string, limit int) ([]RFC, error)

SearchRFCs searches RFCs whose title contains query (case-insensitive).

type Config

type Config struct {
	BaseURL string
	Rate    time.Duration
	Retries int
	Timeout time.Duration
}

Config holds tunable client parameters so callers and the kit factory share one place to adjust them.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns production-safe defaults: 100 ms pacing, 3 retries, 15 s timeout.

type Domain

type Domain struct{}

Domain is the IETF Datatracker driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any accepted input into the canonical (type, id). Inputs starting with "rfc" or all-digits → ("rfc", normalised name). Anything else → ("query", input).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type RFC

type RFC struct {
	Name     string `kit:"id" json:"name"`
	Title    string `json:"title"`
	Pages    int    `json:"pages"`
	Abstract string `json:"abstract"`
	StdLevel string `json:"std_level"` // e.g. "ps", "ds", "std", "bcp", "info", "exp", "hist"
	Updated  string `json:"updated"`
}

RFC is a single IETF RFC document.

type WorkingGroup

type WorkingGroup struct {
	Acronym     string `kit:"id" json:"acronym"`
	Name        string `json:"name"`
	Description string `json:"description"`
	State       string `json:"state"`
}

WorkingGroup is an IETF working group.

Jump to

Keyboard shortcuts

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