server

package
v0.0.0-...-4ca2c20 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHTTPConfig = HTTPConfig{
	Token:   "",
	Address: "127.0.0.1:8080",
}

Functions

func Failed

func Failed(reason string) map[string]any

func NewHTTPStack

func NewHTTPStack(srv http.Handler, token string) http.Handler

func OK

func OK(data any) map[string]any

func StartHTTPServer

func StartHTTPServer(backend *api.Backend, config HTTPConfig) (*http.Server, net.Listener, error)

main loop of http server

Types

type Caller

type Caller interface {
	// Call returns error should be handled by server
	Call(string, Getter) map[string]any
}

func NewCaller

func NewCaller(b *api.Backend) Caller

type Getter

type Getter interface {
	Get(string) any

	// GetString returns empty string if not string type
	GetString(string) string

	Has(string) bool

	Require(...string) string
}

type HTTPConfig

type HTTPConfig struct {
	// Token is http authorization token. If this field is empty string, then generate
	// 16-byte random hex string
	Token string

	// Must be hostname:port
	Address string
}

Jump to

Keyboard shortcuts

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