api

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 9 Imported by: 6 modules, 10 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

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
}

func NewHealthAPI added in v1.4.1

func NewHealthAPI(service string) GinAPI

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
	SetTrustedProxies([]string) GinApiServer
	Static(relativePath, root string) 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