server

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 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.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDomains = Domains{"konghq.com", "konghq.tech"}

DefaultDomains are the domains Kong serves Konnect from. The list is the switch: a deployment pointed at another domain adds it, there is nothing to turn off.

Functions

func IsDomain added in v2.4.0

func IsDomain(domain string) bool

IsDomain reports whether domain is a bare host: parsed as an authority, it gives back the same host, with no scheme, port, path or userinfo. An entry that is a valid host but not a DNS name, e.g. a wildcard, matches no host. An IP is refused: NewServer reads the first label as a region, so it cannot match. An empty string is a bare host too: callers that need a value check it.

Types

type Domains added in v2.4.0

type Domains []string

Domains is the list of domains a Konnect server URL host must belong to.

func NewDomains added in v2.4.0

func NewDomains(flagValue string) (Domains, error)

NewDomains parses the comma-separated list given to --konnect-server-url-domains. An empty list is an error.

func (Domains) Allowed added in v2.4.0

func (d Domains) Allowed(rawURL string) bool

Allowed reports whether rawURL points at one of the domains. The URL is parsed, so only the host the request will be sent to decides: a port, a path and a userinfo part do not take part, and a URL that does not parse is refused.

func (Domains) String added in v2.4.0

func (d Domains) String() string

String returns the list as it is given on the command line.

type Region

type Region string

Region represents a Konnect region.

const (
	// RegionGlobal represents the global region.
	RegionGlobal Region = "global"
)

These are the well-known Konnect regions. The list is not exhaustive.

func NewRegion

func NewRegion(region string) (Region, error)

NewRegion returns a new Region from a string, or an error if the string is not a valid region.

func (Region) String

func (r Region) String() string

String returns the string representation of the Region.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a type to represent a server.

func NewServer

func NewServer[T any](serverURL string) (Server, error)

NewServer creates a new Server from a string. It accepts either a full URL or a hostnameWithoutRegion.

func (Server) Domain added in v2.2.0

func (s Server) Domain() string

Domain returns the registrable domain of the server URL, i.e. the last two DNS labels of the hostname (e.g. "konghq.com" from "us.api.konghq.com"). If the hostname has fewer than two labels it returns the full hostname.

func (Server) GlobalURL added in v2.4.0

func (s Server) GlobalURL() string

GlobalURL returns the URL of the global endpoint of the Server's domain, e.g. "https://global.svc.konghq.com/api" for a Server built from "https://us.svc.konghq.com/api".

func (Server) Region

func (s Server) Region() Region

Region returns the region of the Server.

func (Server) URL

func (s Server) URL() string

URL returns the full URL representation of the Server.

Jump to

Keyboard shortcuts

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