service

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: BSD-3-Clause Imports: 8 Imported by: ? modules, 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 (
	Upgrader = websocket.Upgrader{
		ReadBufferSize:  1024,
		WriteBufferSize: 1024,
		CheckOrigin: func(r *http.Request) bool {
			return true
		},
	}
	ShutdownGracePeriod = 3 * time.Second
)

Functions

This section is empty.

Types

type AssetsDefinition

type AssetsDefinition struct {
	Hosts                 []string // scope to these hosts (see RouteDefinition.Hosts)
	Path                  string
	Vars                  Variables
	Scope                 []string
	Auth                  RouteAuthHandler
	FileSystem            afero.Fs
	Directory             string
	SinglePageApplication bool

	BeforeServe func(w http.ResponseWriter)
}

type Context

type Context interface {
	HandleWith(handler Handler) error
	HandleAuth(Handler) error
	HandleCleanup(Handler) error
	Request() *http.Request
	Writer() http.ResponseWriter
	ParseBody(obj interface{}) error

	RawResponse() bool
	SetRawResponse(val bool)

	Variables() map[string]interface{}
	SetVariable(key string, val interface{})

	Body() []byte
	SetBody([]byte)

	GetStringVariable(key string) (string, error)
	GetStringArrayVariable(key string) ([]string, error)
	GetStringMapVariable(key string) (map[string]interface{}, error)
	GetIntVariable(key string) (int, error)
}

type Handler

type Handler func(ctx Context) (interface{}, error)

type HeadlessAssetsDefinition

type HeadlessAssetsDefinition struct {
	FileSystem            afero.Fs
	Directory             string
	SinglePageApplication bool

	BeforeServe func(w http.ResponseWriter)
}

type LowLevelDefinition

type LowLevelDefinition struct {
	Path       string
	PathPrefix string
	Handler    func(w http.ResponseWriter, r *http.Request)
}

type LowLevelHandlerDefinition added in v1.1.9

type LowLevelHandlerDefinition struct {
	Path       string
	PathPrefix string
	Handler    http.Handler
}

type PermanentRedirect

type PermanentRedirect Redirect

type RawData

type RawData struct {
	ContentType string
	Data        []byte
}

type RawRouteDefinition

type RawRouteDefinition struct {
	Hosts       []string // scope to these hosts (see RouteDefinition.Hosts)
	Path        string
	PathPrefix  string
	Vars        Variables
	Scope       []string
	Auth        RouteAuthHandler
	Handler     Handler
	RawResponse bool
}

type RawStream

type RawStream struct {
	ContentType string
	Stream      io.ReadCloser
}

type Redirect

type Redirect string

type RouteAuthHandler

type RouteAuthHandler struct {
	Validator Handler
	GC        Handler
}

type RouteDefinition

type RouteDefinition struct {
	// Hosts scopes the route to these hosts — a service's <svc>.tau.<fqdn> plus
	// any custom domains bound via domains.hosts. Empty leaves it host-agnostic.
	Hosts       []string
	Path        string
	Vars        Variables
	Scope       []string
	Auth        RouteAuthHandler
	Handler     Handler
	RawResponse bool
}

type Service

type Service interface {
	Context() context.Context
	Start()
	Stop()
	Wait() error
	Error() error
	/********************************/
	GET(*RouteDefinition)
	PUT(*RouteDefinition)
	POST(*RouteDefinition)
	DELETE(*RouteDefinition)
	PATCH(*RouteDefinition)
	ALL(*RouteDefinition)

	Raw(*RawRouteDefinition) *mux.Route
	LowLevel(*LowLevelDefinition) *mux.Route
	LowLevelHandler(*LowLevelHandlerDefinition) *mux.Route

	WebSocket(*WebSocketDefinition)

	ServeAssets(*AssetsDefinition)

	AssetHandler(*HeadlessAssetsDefinition, Context) (interface{}, error)
	LowLevelAssetHandler(*HeadlessAssetsDefinition, http.ResponseWriter, *http.Request) error

	GetListenAddress() (*url.URL, error)
}

type TemporaryRedirect

type TemporaryRedirect Redirect

type Variables

type Variables struct {
	Required []string
	Optional []string
}

type WebSocketConnection added in v1.1.9

type WebSocketConnection interface {
	ReadMessage() (messageType int, p []byte, err error)
	WriteJSON(v interface{}) error
	WriteMessage(messageType int, data []byte) error
	Close() error
	EnableWriteCompression(enable bool)
	SetCloseHandler(func(code int, text string) error)
}

type WebSocketDefinition

type WebSocketDefinition struct {
	Hosts      []string // scope to these hosts (see RouteDefinition.Hosts)
	Path       string
	Vars       Variables
	Scope      []string
	Auth       RouteAuthHandler
	NewHandler func(ctx Context, conn WebSocketConnection) WebSocketHandler
}

type WebSocketHandler

type WebSocketHandler interface {
	In()
	Out()
}

Directories

Path Synopsis
example command
example/handler command
secure/example command

Jump to

Keyboard shortcuts

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