thelittlehost

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 11 Imported by: 0

README

The Little Host for libdns

Go Reference

This package implements the libdns interfaces for The Little Host, allowing you to manage DNS records programmatically.

Configuration

provider := &thelittlehost.Provider{
    APIToken: "tlh_your_api_token_here",
}
Fields
Field Type Required Description
APIToken string Yes Bearer token for API authentication. Generate one in the The Little Host control panel. Tokens are prefixed with tlh_.
Environment variables

This package does not read environment variables directly. Set struct fields explicitly, or use environment variables as defaults in your application:

provider := &thelittlehost.Provider{
    APIToken: os.Getenv("THELITTLEHOST_API_TOKEN"),
}

Usage with CertMagic / Caddy

import "github.com/libdns/thelittlehost"

provider := &thelittlehost.Provider{
    APIToken: "tlh_...",
}

In Caddy JSON config:

{
  "module": "thelittlehost",
  "api_token": "tlh_..."
}

Caveats

  • MX records: Priority is encoded in the Data field as "<preference> <target>" per the libdns convention and is split out for the API automatically.
  • DeleteRecords wildcards: Empty Type, TTL, or Data fields on an input record act as wildcards — any existing record matching the non-empty fields will be deleted.
  • Concurrency: All methods are safe for concurrent use.

License

MIT — see LICENSE.

Documentation

Overview

Package thelittlehost implements a DNS record management client compatible with the libdns interfaces for The Little Host DNS API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// APIToken is the bearer token for authentication with The Little Host API.
	// Tokens are prefixed with "tlh_" and can be generated in the control panel.
	APIToken string `json:"api_token,omitempty"`
	// contains filtered or unexported fields
}

Provider facilitates DNS record manipulation with The Little Host.

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)

AppendRecords adds records to the zone without replacing any existing records. It returns the records that were added. Record names must be relative to the zone.

func (*Provider) DeleteRecords

func (p *Provider) DeleteRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)

DeleteRecords deletes the specified records from the zone. Records that don't exist in the zone are silently ignored. Empty Type, TTL, or Data fields in the input act as wildcards.

func (*Provider) GetRecords

func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)

GetRecords lists all the records in the zone. zone must be a fully-qualified domain name with a trailing dot (e.g. "example.com."). Record names in the returned slice are relative to the zone.

func (*Provider) SetRecords

func (p *Provider) SetRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)

SetRecords sets the records in the zone, either by updating existing records or creating new ones. For each (name, type) pair present in recs, it ensures the zone contains exactly those records — surplus existing records for that pair are deleted. Records for (name, type) pairs not mentioned in recs are left untouched. It returns the records that were set.

Jump to

Keyboard shortcuts

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