server

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServer

type APIServer interface {
	// Setup setups the server engine, like custom routers or middlewares.
	// Setup should be called before Run.
	Setup(SetupFunc) error
	// Run starts the api server engine.
	Run() error
	// Close shutdowns the api server engine.
	Close()
}

APIServer is the interface of the api server.

func New

func New(options *Options) APIServer

New returns a new api server instance.

type HTTPOptions

type HTTPOptions struct {
	BindAddress string `json:"bind-address" mapstructure:"bind-address"`
	BindPort    int    `json:"bind-port"    mapstructure:"bind-port"`
}

HTTPOptions contains configuration for http server.

func (*HTTPOptions) AddFlags

func (o *HTTPOptions) AddFlags(fs *pflag.FlagSet)

func (*HTTPOptions) Address

func (o *HTTPOptions) Address() string

Address join host IP address and host port number into an address string, like: 0.0.0.0:8443.

func (*HTTPOptions) Validate

func (o *HTTPOptions) Validate() []error

type HTTPSOptions

type HTTPSOptions struct {
	Enabled     bool       `json:"enabled"      mapstructure:"enabled"`
	BindAddress string     `json:"bind-address" mapstructure:"bind-address"`
	BindPort    int        `json:"bind-port"    mapstructure:"bind-port"`
	TLS         TLSOptions `json:"tls"          mapstructure:"tls"`
}

HTTPSOptions contains configuration for https server.

func (*HTTPSOptions) AddFlags

func (o *HTTPSOptions) AddFlags(fs *pflag.FlagSet)

func (*HTTPSOptions) Address

func (o *HTTPSOptions) Address() string

Address join host IP address and host port number into an address string, like: 0.0.0.0:8443.

func (*HTTPSOptions) Validate

func (o *HTTPSOptions) Validate() []error

type Options

type Options struct {
	Healthz     bool     `json:"healthz"     mapstructure:"healthz"`
	Middlewares []string `json:"middlewares" mapstructure:"middlewares"`
	Profiling   bool     `json:"profiling"   mapstructure:"profiling"`
	Metrics     bool     `json:"metrics"     mapstructure:"metrics"`

	HTTP  *HTTPOptions  `json:"http"  mapstructure:"http"`
	HTTPS *HTTPSOptions `json:"https" mapstructure:"https"`
}

Options contains configuration options for api server.

func NewOptions

func NewOptions() *Options

NewOptions return a new options for server.

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

func (*Options) Validate

func (o *Options) Validate() []error

type SetupFunc

type SetupFunc func(g *gin.Engine) error

SetupFunc is the func used to set up the engine.

type TLSOptions

type TLSOptions struct {
	// CertFile is a file containing a PEM-encoded certificate, and possibly the complete certificate chain
	CertFile string `json:"cert-file"        mapstructure:"cert-file"`
	// KeyFile is a file containing a PEM-encoded private key for the certificate specified by CertFile
	KeyFile string `json:"private-key-file" mapstructure:"private-key-file"`
}

TLSOptions contains configuration for TLS.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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