httpserver

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Category is the category of HTTPServer.
	Category = supervisor.CategoryTrafficGate

	// Kind is the kind of HTTPServer.
	Kind = "HTTPServer"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPServer

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

HTTPServer is Object HTTPServer.

func (*HTTPServer) Category

func (hs *HTTPServer) Category() supervisor.ObjectCategory

Category returns the category of HTTPServer.

func (*HTTPServer) Close

func (hs *HTTPServer) Close()

Close closes HTTPServer.

func (*HTTPServer) DefaultSpec

func (hs *HTTPServer) DefaultSpec() interface{}

DefaultSpec returns the default spec of HTTPServer.

func (*HTTPServer) Inherit

func (hs *HTTPServer) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object, muxMapper protocol.MuxMapper)

Inherit inherits previous generation of HTTPServer.

func (*HTTPServer) Init

func (hs *HTTPServer) Init(superSpec *supervisor.Spec, muxMapper protocol.MuxMapper)

Init initializes HTTPServer.

func (*HTTPServer) Kind

func (hs *HTTPServer) Kind() string

Kind returns the kind of HTTPServer.

func (*HTTPServer) Status

func (hs *HTTPServer) Status() *supervisor.Status

Status is the wrapper of runtime's Status.

type Header struct {
	Key     string   `yaml:"key" jsonschema:"required"`
	Values  []string `yaml:"values,omitempty" jsonschema:"omitempty,uniqueItems=true"`
	Regexp  string   `yaml:"regexp,omitempty" jsonschema:"omitempty,format=regexp"`
	Backend string   `yaml:"backend" jsonschema:"required"`
	// contains filtered or unexported fields
}

Header is the third level entry of router. A header entry is always under a specific path entry, that is to mean the headers entry will only be checked after a path entry matched. However, the headers entry has a higher priority than the path entry itself.

func (*Header) Validate

func (h *Header) Validate() error

Validate validates Header.

type Path

type Path struct {
	IPFilter      *ipfilter.Spec `yaml:"ipFilter,omitempty" jsonschema:"omitempty"`
	Path          string         `yaml:"path,omitempty" jsonschema:"omitempty,pattern=^/"`
	PathPrefix    string         `yaml:"pathPrefix,omitempty" jsonschema:"omitempty,pattern=^/"`
	PathRegexp    string         `yaml:"pathRegexp,omitempty" jsonschema:"omitempty,format=regexp"`
	RewriteTarget string         `yaml:"rewriteTarget" jsonschema:"omitempty"`
	Methods       []string       `yaml:"methods,omitempty" jsonschema:"omitempty,uniqueItems=true,format=httpmethod-array"`
	Backend       string         `yaml:"backend" jsonschema:"required"`
	Headers       []*Header      `yaml:"headers" jsonschema:"omitempty"`
}

Path is second level entry of router.

type Rule

type Rule struct {
	// NOTICE: If the field is a pointer, it must have `omitempty` in tag `yaml`
	// when it has `omitempty` in tag `jsonschema`.
	// Otherwise it will output null value, which is invalid in json schema (the type is object).
	// the original reason is the jsonscheme(genjs) has not support multiple types.
	// Reference: https://github.com/alecthomas/jsonschema/issues/30
	// In the future if we have the scenario where we need marshal the field, but omitempty
	// in the schema, we are suppose to support multiple types on our own.
	IPFilter   *ipfilter.Spec `yaml:"ipFilter,omitempty" jsonschema:"omitempty"`
	Host       string         `yaml:"host" jsonschema:"omitempty"`
	HostRegexp string         `yaml:"hostRegexp" jsonschema:"omitempty,format=regexp"`
	Paths      []*Path        `yaml:"paths" jsonschema:"omitempty"`
}

Rule is first level entry of router.

type Spec

type Spec struct {
	HTTP3            bool          `yaml:"http3" jsonschema:"omitempty"`
	Port             uint16        `yaml:"port" jsonschema:"required,minimum=1"`
	KeepAlive        bool          `yaml:"keepAlive" jsonschema:"required"`
	KeepAliveTimeout string        `yaml:"keepAliveTimeout" jsonschema:"omitempty,format=duration"`
	MaxConnections   uint32        `yaml:"maxConnections" jsonschema:"omitempty,minimum=1"`
	HTTPS            bool          `yaml:"https" jsonschema:"required"`
	CacheSize        uint32        `yaml:"cacheSize" jsonschema:"omitempty"`
	XForwardedFor    bool          `yaml:"xForwardedFor" jsonschema:"omitempty"`
	Tracing          *tracing.Spec `yaml:"tracing" jsonschema:"omitempty"`

	// Support multiple certs, preserve the certbase64 and keybase64
	// for backward compatibility
	CertBase64 string `yaml:"certBase64" jsonschema:"omitempty,format=base64"`
	KeyBase64  string `yaml:"keyBase64" jsonschema:"omitempty,format=base64"`

	// Certs saved as map, key is domain name, value is cert
	Certs map[string]string `yaml:"certs" jsonschema:"omitempty"`
	// Keys saved as map, key is domain name, value is secret
	Keys map[string]string `yaml:"keys" jsonschema:"omitempty"`

	IPFilter *ipfilter.Spec `yaml:"ipFilter,omitempty" jsonschema:"omitempty"`
	Rules    []*Rule        `yaml:"rules" jsonschema:"omitempty"`
}

Spec describes the HTTPServer.

func (*Spec) Validate

func (spec *Spec) Validate() error

Validate validates HTTPServerSpec.

type Status

type Status struct {
	Health string `yaml:"health"`

	State stateType `yaml:"state"`
	Error string    `yaml:"error,omitempty"`

	*httpstat.Status
	TopN *topn.Status `yaml:"topN"`
}

Status contains all status generated by runtime, for displaying to users.

Jump to

Keyboard shortcuts

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