api

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 ErrorOutputAPI added in v1.0.0

type ErrorOutputAPI interface {
	GinOutputErr(c *gin.Context, err error)
}

func NewErrorOutputAPI added in v1.0.0

func NewErrorOutputAPI(service string) ErrorOutputAPI

type GinAPI added in v1.0.0

type GinAPI interface {
	GetAPIs() []*GinApiHandler
	GetName() string
}

type GinApiHandler added in v1.0.0

type GinApiHandler struct {
	Method  string
	Path    string
	Handler func(c *gin.Context)
	Auth    bool
	Group   []auth.UserPerm
}

type GinApiServer added in v1.0.0

type GinApiServer interface {
	AddAPIs(handlers ...GinAPI) GinApiServer
	Middles(mids ...mid.GinMiddle) GinApiServer
	SetAuth(authmid mid.AuthGinMidInter) GinApiServer
	Run(port string) error
}

func NewGinApiServer added in v1.0.0

func NewGinApiServer(mode string) GinApiServer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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