host

package
v0.0.0-...-b511e1a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Authorization = "Authorization"
	TimeoutFlag   = "TO"
	XRequestId    = "X-Request-Id"
)
View Source
const (
	UrnScheme    = "urn"
	UrnSeparator = ":"
)
View Source
const (
	PkgPath = "github/advanced-go/core/host"
)
View Source
const (
	RouteName = "host"
)

Variables

This section is empty.

Functions

func HttpHandler

func HttpHandler(w http.ResponseWriter, r *http.Request)

HttpHandler - handler for messaging

func Milliseconds

func Milliseconds(duration time.Duration) int

Milliseconds - convert time.Duration to milliseconds

func RegisterHandler

func RegisterHandler(path string, handler HttpHandlerFunc) error

RegisterHandler - add a path and Http handler to the proxy TO DO : panic on duplicate handler and pattern combination

func SetAuthHandler

func SetAuthHandler(h func(w http.ResponseWriter, r *http.Request), ok func(int) bool)

func SetHostTimeout

func SetHostTimeout(d time.Duration)

func Startup

func Startup(duration time.Duration, content ContentMap) bool

Startup - templated function to start all registered resources.

func UprootUrn

func UprootUrn(uri string) (nid, nss string, ok bool)

UprootUrn - uproot an embedded urn in a uri

Types

type ContentMap

type ContentMap map[string]map[string]string

ContentMap - slice of any content to be included in a message

type HttpHandlerFunc

type HttpHandlerFunc func(w http.ResponseWriter, r *http.Request)

func NewAccessLogIntermediary

func NewAccessLogIntermediary(routeName string, c2 HttpHandlerFunc) HttpHandlerFunc

func NewConditionalIntermediary

func NewConditionalIntermediary(c1 HttpHandlerFunc, c2 HttpHandlerFunc, ok func(int) bool) HttpHandlerFunc

func NewHostTimeoutIntermediary

func NewHostTimeoutIntermediary(d time.Duration, c2 HttpHandlerFunc) HttpHandlerFunc

func NewIngressTimeoutIntermediary

func NewIngressTimeoutIntermediary(routeName string, d time.Duration, c2 HttpHandlerFunc) HttpHandlerFunc

type Proxy

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

Proxy - key value pairs of a URI -> HttpHandler

func NewProxy

func NewProxy() *Proxy

NewProxy - create a new Proxy

func (*Proxy) Lookup

func (p *Proxy) Lookup(uri string) func(w http.ResponseWriter, r *http.Request)

Lookup - get an HttpHandler from the proxy, using a URI as the key

func (*Proxy) LookupByNID

func (p *Proxy) LookupByNID(nid string) func(w http.ResponseWriter, r *http.Request)

LookupByNID - get an HttpHandler from the proxy, using an NID as a key

func (*Proxy) Register

func (p *Proxy) Register(uri string, handler func(w http.ResponseWriter, r *http.Request)) error

Register - add an HttpHandler to the proxy

Jump to

Keyboard shortcuts

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