apitool

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 19 Imported by: 0

README

api-toolkit

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoGinApiRun

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

func AutoGinApiServer

func AutoGinApiServer(cfg *Config) (*http.Server, 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

type Config struct {
	Service        string
	GinMode        string
	IsMockAuth     bool
	ApiPort        int
	TrustedProxies []string
	Debug          bool // autopaho and paho debug output requested

	Logger Log
	// contains filtered or unexported fields
}

config holds the configuration

func GetConfigFromEnv

func GetConfigFromEnv() (*Config, error)

getConfig - Retrieves the configuration from the environment

func (*Config) AddProms

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

func (*Config) SetAPIs

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

func (*Config) SetAuth

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

func (*Config) SetMiddles

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

func (*Config) SetPreAuthMiddles

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

func (*Config) SetServerErrorHandler

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

type GinAPI

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

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
	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 Log

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