middleware

package
v0.0.0-...-15297c8 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package middleware provides some types and functions common among middleware.

Index

Constants

View Source
const Namespace = "coredns"

Namespace is the namespace used for the metrics.

Variables

This section is empty.

Functions

func Error

func Error(name string, err error) error

Error returns err with 'middleware/name: ' prefixed to it.

Types

type Addr

type Addr string // Addr resprents an address in the Corefile.

Addr resprents an address in the Corefile.

func (Addr) Normalize

func (a Addr) Normalize() string

Normalize will return a normalized address, if not port is specified port 53 is added, otherwise the port will be left as is.

type Handler

type Handler interface {
	ServeDNS(context.Context, dns.ResponseWriter, *dns.Msg) (int, error)
}

Handler is like dns.Handler except ServeDNS may return an rcode and/or error.

If ServeDNS writes to the response body, it should return a status code. If the status code is not one of the following:

* SERVFAIL (dns.RcodeServerFailure)

* REFUSED (dns.RecodeRefused)

* FORMERR (dns.RcodeFormatError)

* NOTIMP (dns.RcodeNotImplemented)

CoreDNS assumes *no* reply has yet been written. All other response codes signal other handlers above it that the response message is already written, and that they should not write to it also.

If ServeDNS encounters an error, it should return the error value so it can be logged by designated error-handling middleware.

If writing a response after calling another ServeDNS method, the returned rcode SHOULD be used when writing the response.

If handling errors after calling another ServeDNS method, the returned error value SHOULD be logged or handled accordingly.

Otherwise, return values should be propagated down the middleware chain by returning them unchanged.

type HandlerFunc

type HandlerFunc func(context.Context, dns.ResponseWriter, *dns.Msg) (int, error)

HandlerFunc is a convenience type like dns.HandlerFunc, except ServeDNS returns an rcode and an error. See Handler documentation for more information.

func (HandlerFunc) ServeDNS

func (f HandlerFunc) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the Handler interface.

type Host

type Host string // Host represents a host from the Corefile, may contain port.

Host represents a host from the Corefile, may contain port.

func (Host) Normalize

func (h Host) Normalize() string

Normalize will return the host portion of host, stripping of any port. The host will also be fully qualified and lowercased.

type Middleware

type Middleware func(Handler) Handler

Middleware is the middle layer which represents the traditional idea of middleware: it chains one Handler to the next by being passed the next Handler in the chain.

type Name

type Name string

Name represents a domain name.

func (Name) Matches

func (n Name) Matches(child string) bool

Matches checks to see if other is a subdomain (or the same domain) of n. This method assures that names can be easily and consistently matched.

func (Name) Normalize

func (n Name) Normalize() string

Normalize lowercases and makes n fully qualified.

type Zones

type Zones []string

Zones respresents a lists of zone names.

func (Zones) Matches

func (z Zones) Matches(qname string) string

Matches checks is qname is a subdomain of any of the zones in z. The match will return the most specific zones that matches other. The empty string signals a not found condition.

func (Zones) Normalize

func (z Zones) Normalize()

Normalize fully qualifies all zones in z.

Directories

Path Synopsis
Package errors implements an HTTP error handling middleware.
Package errors implements an HTTP error handling middleware.
Package etcd provides the etcd backend.
Package etcd provides the etcd backend.
msg
tree
Package tree implements Left-Leaning Red Black trees as described by Robert Sedgewick.
Package tree implements Left-Leaning Red Black trees as described by Robert Sedgewick.
Package kubernetes provides the kubernetes backend.
Package kubernetes provides the kubernetes backend.
Package loadbalance is middleware for rewriting responses to do "load balancing"
Package loadbalance is middleware for rewriting responses to do "load balancing"
Package log implements basic but useful request (access) logging middleware.
Package log implements basic but useful request (access) logging middleware.
pkg
singleflight
Package singleflight provides a duplicate function call suppression mechanism.
Package singleflight provides a duplicate function call suppression mechanism.
Package proxy is middleware that proxies requests.
Package proxy is middleware that proxies requests.
Package rewrite is middleware for rewriting requests internally to something different.
Package rewrite is middleware for rewriting requests internally to something different.

Jump to

Keyboard shortcuts

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