api

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: MIT Imports: 6 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OutputErr

func OutputErr(w http.ResponseWriter, err error)

func OutputJson added in v0.13.0

func OutputJson(w http.ResponseWriter, statusCode int, data interface{})

Types

type API

type API interface {
	GetAPIs() []*APIHandler
	GetName() string
}

type APIConf

type APIConf struct {
	Port   string          `yaml:"port,omitempty"`
	Cors   bool            `yaml:"cors"`
	Middle map[string]bool `yaml:"middle,omitempty"`
	Apis   map[string]bool `yaml:"api,omitempty"`
}

func NewApiConf added in v0.18.0

func NewApiConf(port string, cors bool, ignoreMids []string, ignoreApis []string) *APIConf

func (*APIConf) EnableCORS

func (ac *APIConf) EnableCORS() bool

func (*APIConf) GetPort

func (ac *APIConf) GetPort() string

func (*APIConf) InitAPI

func (ac *APIConf) InitAPI(
	r *mux.Router,
	middles []mid.Middle,
	authMiddle mid.AuthMidInter,
	apis ...API,
)

type APIHandler

type APIHandler struct {
	Path   string
	Next   func(http.ResponseWriter, *http.Request)
	Method string
	Auth   bool
	Group  []auth.UserPerm
}

type ApiDI

type ApiDI interface {
	InitAPI(
		r *mux.Router,
		middles []mid.Middle,
		authMiddle mid.AuthMidInter,
		apis ...API,
	)
	GetPort() string
	EnableCORS() bool
}

type ApiError

type ApiError interface {
	GetStatus() int
	GetErrorKey() string
	GetErrorMsg() string
	error
}

func NewApiError

func NewApiError(status int, msg string) ApiError

func NewApiErrorWithKey added in v0.13.0

func NewApiErrorWithKey(status int, msg string, key string) ApiError

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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