apiserver

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware() gin.HandlerFunc

func GetRouter

func GetRouter(mgr process.IManager) (*gin.Engine, error)

func SetDebugMode

func SetDebugMode(debug bool)

func Spawn

func Spawn(mgr process.IManager, lgr logger.ILogger, config *Config) (*process.Process, error)

Types

type Config

type Config struct {
	Addr    string `json:"address"`
	Cert    string `json:"cert_file"`
	Key     string `json:"key_file"`
	UseTLS  bool   `json:"use_tls"`
	LogFile string `json:"log_file"`
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(addr, log, cert, key string, tls bool) *Config

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) Host added in v0.3.3

func (c *Config) Host() (string, error)

func (*Config) Port added in v0.3.3

func (c *Config) Port() (int, error)

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

func NewDefaultDispatcher

func NewDefaultDispatcher() *Dispatcher

func NewDispatcher

func NewDispatcher(lgr logger.ILogger, config *Config) *Dispatcher

func (*Dispatcher) GetRouter

func (d *Dispatcher) GetRouter() *gin.Engine

func (*Dispatcher) Start

func (d *Dispatcher) Start()

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

type DispatcherProc

type DispatcherProc struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewDispatcherProc

func NewDispatcherProc(lgr logger.ILogger, config *Config) *DispatcherProc

func (*DispatcherProc) Action

func (p *DispatcherProc) Action(state **process.State)

type Document

type Document struct {
	Data    interface{}    `json:"data,omitempty"`
	Count   int64          `json:"count"`
	Error   *ErrorDocument `json:"error,omitempty"`
	Elapsed string         `json:"elapsed_time,omitempty"`
	// contains filtered or unexported fields
}

nolint:govet

func NewDocument

func NewDocument(status int, data interface{}) *Document

func NewErrorDocument

func NewErrorDocument(status int, msg string) *Document

func (*Document) AddHeader

func (d *Document) AddHeader(key, value string)

func (*Document) SetError

func (d *Document) SetError(err *ErrorDocument)

func (*Document) Status

func (d *Document) Status() int

func (*Document) Write

func (d *Document) Write(ctx *gin.Context)

type ErrorDocument

type ErrorDocument struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

func NewError

func NewError(status int, msg string) *ErrorDocument

type IServer

type IServer interface {
	ListenAndServeTLS(string, string) error
	ListenAndServe() error
	Shutdown(context.Context) error
	SetTLSConfig(*tls.Config)
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewDefaultServer

func NewDefaultServer() *Server

func NewServer

func NewServer(addr string, router *gin.Engine) *Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) ListenAndServeTLS

func (s *Server) ListenAndServeTLS(cert, key string) error

func (*Server) SetTLSConfig

func (s *Server) SetTLSConfig(conf *tls.Config)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Jump to

Keyboard shortcuts

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