apitool

package module
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 21 Imported by: 2 modules, 1 package

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.

README

api-toolkit

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoGinApiRun added in v1.1.1

func AutoGinApiRun(ctx context.Context, cfg *Config) error

func AutoGinApiRunWithBindUser added in v1.7.0

func AutoGinApiRunWithBindUser[T mid.BindUser](ctx context.Context, cfg *ConfigWithBindUser[T]) error

func GetHost

func GetHost(req *http.Request) string

func GetPostValue

func GetPostValue(req *http.Request, defaultEmpty bool, keys []string) (map[string]interface{}, error)

func ParserDataRequest

func ParserDataRequest(req *http.Request, data interface{}) error

Types

type Config added in v1.1.0

type Config struct {
	Service           string
	GinMode           string
	IsMockAuth        bool
	MockAuthSecret    string
	ApiPort           int
	TrustedProxies    []string
	Debug             bool // autopaho and paho debug output requested
	SessionHeaderName string
	SessionExpired    time.Duration

	Logger Log
	// contains filtered or unexported fields
}

config holds the configuration

func GetConfigFromEnv added in v1.1.0

func GetConfigFromEnv() (*Config, error)

getConfig - Retrieves the configuration from the environment

func (*Config) AddProms added in v1.1.0

func (cfg *Config) AddProms(c ...prometheus.Collector)

func (*Config) SetAPIs added in v1.1.0

func (cfg *Config) SetAPIs(apis ...GinAPI)

func (*Config) SetAuth added in v1.1.0

func (cfg *Config) SetAuth(authmid auth.GinAuthMidInter)

func (*Config) SetMiddles added in v1.1.0

func (cfg *Config) SetMiddles(mids ...mid.GinMiddle)

func (*Config) SetPreAuthMiddles added in v1.2.0

func (cfg *Config) SetPreAuthMiddles(mids ...mid.GinMiddle)

func (*Config) SetServerErrorHandler added in v1.1.0

func (cfg *Config) SetServerErrorHandler(handler errors.GinServerErrorHandler)

func (*Config) SetSessionStore added in v1.6.0

func (cfg *Config) SetSessionStore(store session.ManagerStore)

type ConfigWithBindUser added in v1.7.0

type ConfigWithBindUser[T mid.BindUser] struct {
	CtxUserKey string
	*Config
	// contains filtered or unexported fields
}

func GetConfigWithBindUserFromEnv added in v1.7.0

func GetConfigWithBindUserFromEnv[T mid.BindUser](bind T) (*ConfigWithBindUser[T], error)

func (*ConfigWithBindUser[T]) SetAPIs added in v1.7.0

func (cfg *ConfigWithBindUser[T]) SetAPIs(apis ...GinAPIWithBindUser[T])

type GinAPI

type GinAPI interface {
	errors.ApiErrorHandler
	GetAPIs() []*GinApiHandler
}

type GinAPIWithBindUser added in v1.7.0

type GinAPIWithBindUser[T mid.BindUser] interface {
	GinAPI
	SetReqUserHandler(ctxUserKey string)
	GetReqUser(c *gin.Context) T
}

type GinApiHandler

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

type GinApiServer

type GinApiServer interface {
	AddAPIs(handlers ...GinAPI) GinApiServer
	Middles(mids ...mid.GinMiddle) GinApiServer
	SetServerErrorHandler(errors.GinServerErrorHandler) GinApiServer
	SetAuth(authmid auth.GinAuthMidInter) GinApiServer
	SetTrustedProxies([]string) GinApiServer
	SetPromhttp(c ...prometheus.Collector) GinApiServer
	SetSession(sessionHeaderName string, store session.ManagerStore, expired time.Duration) GinApiServer
	Static(relativePath, root string) GinApiServer
	Run(port int) error

	GetServer(port int) *http.Server
	// contains filtered or unexported methods
}

func NewGinApiServer

func NewGinApiServer(mode string, service string) GinApiServer

type GinReqUserHandler added in v1.7.0

type GinReqUserHandler[T mid.BindUser] struct {
	// contains filtered or unexported fields
}

func (*GinReqUserHandler[T]) GetReqUser added in v1.7.0

func (h *GinReqUserHandler[T]) GetReqUser(c *gin.Context) T

func (*GinReqUserHandler[T]) SetReqUserHandler added in v1.7.0

func (h *GinReqUserHandler[T]) SetReqUserHandler(ctxUserKey string)

type Log added in v1.1.0

type Log interface {
	Infof(format string, a ...any)
	Fatalf(format string, a ...any)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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