hap

package module
v2.0.0-alpha.37 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiPanicHandler

func ApiPanicHandler(w http.ResponseWriter, err any)

func GetGlobalCORS

func GetGlobalCORS() (bool, []string)

func MatchPreferredLanguage

func MatchPreferredLanguage(r *http.Request) *message.Printer

func RawPanicHandler

func RawPanicHandler(w http.ResponseWriter, err any)

func RawReply

func RawReply(code int) *reply

func Register

func Register(a API, mx ...*http.ServeMux)

func Reply

func Reply(code int) *reply

func SetGlobalCORS

func SetGlobalCORS(enable bool, origin ...string)

func WithGlobalActions

func WithGlobalActions(as ...Action)

func WithLangSpecifier

func WithLangSpecifier(lang string)

Types

type API

type API interface {
	Endpoint() string
	Spec() []ApiSpec
	http.Handler
}

type Action

type Action func(*arg.Args, http.ResponseWriter, *http.Request) any

func AllowRemoteFrom

func AllowRemoteFrom(forwarded bool, ipn ...net.IPNet) Action

func GlocalActions

func GlocalActions() []Action

type ApiSpec

type ApiSpec struct {
	Endpoint string      `json:"endpoint"`
	Method   string      `json:"method"`
	Help     []string    `json:"help,omitempty"`
	Params   []ParamSpec `json:"params,omitempty"`
	Output   []ReplyDesc `json:"output,omitempty"`
	Tags     url.Values  `json:"tags,omitempty"`
}

func Specs

func Specs(endPoint, method string) (as []ApiSpec)

type PanicHandler

type PanicHandler func(http.ResponseWriter, any)

type ParamSpec

type ParamSpec struct {
	Name     string     `json:"name"`
	Type     string     `json:"type"`
	Required bool       `json:"required"`
	Default  *string    `json:"default,omitempty"`
	Rules    [][]string `json:"rules,omitempty"`
	Help     []string   `json:"help,omitempty"`
}

type ReplyDesc

type ReplyDesc struct {
	Mime string    `json:"mime"`
	Raw  bool      `json:"raw"`
	Spec ReplySpec `json:"spec"`
}

type ReplySpec

type ReplySpec = *reply

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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