httpnet

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 11 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

http.net DNS for libdns

Go Reference

This package implements the libdns interfaces for http.net, allowing DNS records to be managed via the http.net partner API.

Authenticating

Create an API token in the http.net partner portal (API documentation: https://www.http.net/docs/api/) and pass it to the provider:

import "github.com/libdns/httpnet"

provider := &httpnet.Provider{
    AuthToken: "your-api-token",
}

records, err := provider.GetRecords(context.Background(), "example.com.")

The Provider implements RecordGetter, RecordAppender, RecordSetter, RecordDeleter, and ZoneLister.

Any DNS record type accepted by the http.net API is supported: records are parsed into the matching typed libdns.Record (libdns.Address, libdns.MX, libdns.TXT, …) via libdns.RR.Parse().

Caveats

TTL floor

The http.net API enforces a 60-second minimum TTL. Lower values (including zero) are silently raised to 60 before being sent, to avoid request rejection.

Asynchronous writes

Write operations may return a pending status with an empty record list. The provider handles this by performing a follow-up read, so callers still receive records with their assigned IDs.

Atomicity

Updates within a single call are applied atomically by recordsUpdate, but concurrent modifications from separate processes to the same RRset may result in inconsistent state. Ensure concurrent processes operate on different RRsets.

Testing

Unit tests run against an in-process mock server and require no credentials:

go test ./...

Integration tests against the live http.net API are opt-in via environment variables:

export HTTPNET_AUTH_TOKEN=<your-api-token>
export HTTPNET_TEST_ZONE=example.com.   # a zone you control; trailing dot required
go test -v ./...

Tests that find these variables unset are skipped automatically.

License

MIT

Documentation

Overview

Package httpnet implements a libdns provider for the http.net DNS API.

Authentication uses an API token from the http.net partner portal. Write operations may return a "pending" status; the package handles this by falling back to a follow-up read to retrieve assigned record IDs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// AuthToken is the http.net API authentication token.
	AuthToken string `json:"auth_token,omitempty"`

	// BaseURL optionally overrides the default API base URL. Useful for tests.
	BaseURL string `json:"base_url,omitempty"`

	// HTTPClient optionally overrides the default HTTP client.
	HTTPClient *http.Client `json:"-"`
	// contains filtered or unexported fields
}

Provider implements the libdns DNS provider interfaces for http.net.

func (*Provider) AppendRecords

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

AppendRecords adds records to the zone. It returns the records that were added.

func (*Provider) DeleteRecords

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

DeleteRecords deletes records from the zone. Matching rules (per libdns v1):

  • If a record's RR has both Name and non-empty Data, delete the record whose (name, type, content) matches exactly.
  • If a record's RR has Name and Type but empty Data, delete the entire RRset at that name and type.

Returns the records that were deleted.

func (*Provider) GetRecords

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

GetRecords lists all the records in the zone.

func (*Provider) ListZones

func (p *Provider) ListZones(ctx context.Context) ([]libdns.Zone, error)

ListZones returns the zones available in the http.net account.

func (*Provider) SetRecords

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

SetRecords replaces the RRset (all records sharing the same name and type) for each (name, type) present in records. Existing records at those RRsets that are not in the input are deleted. Other RRsets in the zone are untouched.

Jump to

Keyboard shortcuts

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