hap

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

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGlobalCORS

func GetGlobalCORS() (bool, []string)

func HandlePanic

func HandlePanic(w http.ResponseWriter, err any)

func MatchPreferredLanguage

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

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 WithApiPanicHandler

func WithApiPanicHandler()

func WithGlobalActions

func WithGlobalActions(as ...Action)

func WithLangSpecifier

func WithLangSpecifier(lang string)

func WithRawPanicHandler

func WithRawPanicHandler()

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 ParamSpec

type ParamSpec struct {
	Name     string     `json:"name"`
	Type     string     `json:"type"`
	Required bool       `json:"required"`
	Default  string     `json:"default"`
	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