server

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPLogger

func HTTPLogger(logger *logging.Logger) heligo.Middleware

Types

type Config

type Config struct {
	Address              string          `comment:"Server address and port (default: 0.0.0.0:4000)"`
	CertFile             string          `comment:"TLS certificate file (default: '')"`
	KeyFile              string          `comment:"TLS certificate key file (default: '')"`
	AllowAnon            bool            `comment:"Allow unauthenticated connections (default: false)"`
	JWTSecret            string          `comment:"Secret for JWT tokens"`
	SessionMode          string          `comment:"Session mode: none, role (default: role)"`
	EnableAdminRoute     bool            `comment:"Enable administration of databases and tables (default: false)"`
	EnableAdminUI        bool            `comment:"Enable Admin dashboard (default: false)"`
	EnableAPIRoute       bool            `comment:"Enable API access (default: true)"`
	BaseAPIURL           string          `comment:"Base URL for the API (default: /api)"`
	ShortAPIURL          bool            `comment:"Avoid database name in API URL (needs a single allowed database)"`
	BaseAdminURL         string          `comment:"Base URL for the Admin API (default: /admin)"`
	CORSAllowedOrigins   []string        `comment:"CORS Access-Control-Allow-Origin (default: [*] for all)"`
	CORSAllowCredentials bool            `comment:"CORS Access-Control-Allow-Credentials (default: false)"`
	EnableDebugRoute     bool            `comment:"Enable debug access (default: false)"`
	PluginDir            string          `comment:"Plugins' directory (default: ./_plugins)"`
	Plugins              []string        `comment:"Ordered list of plugins (default: [])"`
	ReadTimeout          int64           `comment:"The maximum duration (seconds) for reading the entire request, including the body (default: 60)"`
	WriteTimeout         int64           `comment:"The maximum duration before timing out writes of the response (default: 60)"`
	RequestMaxBytes      int64           `comment:"Max bytes allowed in requests, to limit the size of incoming request bodies (default: 1M, 0 for unlimited)"`
	Database             database.Config `comment:"Database configuration"`
	Logging              logging.Config  `comment:"Logging configuration"`
}

Config holds the current configuration

type ConfigOptions

type ConfigOptions struct {
	ConfigFilePath string
	SkipFlags      bool
	SkipEnv        bool
}

type Server

type Server struct {
	Config *Config

	DBE  *database.DbEngine
	HTTP *http.Server

	OnBeforeStart    func(*Server)
	OnBeforeShutdown func(*Server)
	// contains filtered or unexported fields
}

func NewServer

func NewServer() (*Server, error)

func NewServerWithConfig

func NewServerWithConfig(config map[string]any, configOpts *ConfigOptions) (*Server, error)

func (*Server) AllowAnon added in v0.2.2

func (s *Server) AllowAnon() bool

func (*Server) AnonRole added in v0.2.2

func (s *Server) AnonRole() string

func (*Server) BaseAPIURL added in v0.2.2

func (s *Server) BaseAPIURL() string

func (*Server) BaseAdminURL added in v0.2.2

func (s *Server) BaseAdminURL() string

func (*Server) GetDBE added in v0.2.3

func (s *Server) GetDBE() *database.DbEngine

func (*Server) GetDatabase added in v0.2.3

func (s *Server) GetDatabase(ctx context.Context, name string) (*database.Database, error)

func (*Server) GetLogger added in v0.2.7

func (s *Server) GetLogger() *logging.Logger

func (*Server) GetMainDatabase added in v0.2.4

func (s *Server) GetMainDatabase(ctx context.Context) (*database.Database, error)

func (*Server) GetRouter

func (s *Server) GetRouter() *heligo.Router

func (*Server) HasShortAPIURL added in v0.2.2

func (s *Server) HasShortAPIURL() bool

func (*Server) JWTSecret added in v0.2.2

func (s *Server) JWTSecret() string

func (*Server) MiddlewareDBE added in v0.2.2

func (s *Server) MiddlewareDBE() heligo.Middleware

func (*Server) MiddlewareStd added in v0.2.2

func (s *Server) MiddlewareStd() heligo.Middleware

func (*Server) MiddlewareWithDbName added in v0.2.2

func (s *Server) MiddlewareWithDbName(dbname string) heligo.Middleware

func (*Server) RequestMaxBytes added in v0.2.6

func (s *Server) RequestMaxBytes() int64

func (*Server) Run added in v0.1.2

func (s *Server) Run()

func (*Server) SessionManager added in v0.2.2

func (s *Server) SessionManager() *authn.SessionManager

func (*Server) SessionStatistics added in v0.2.2

func (s *Server) SessionStatistics() authn.SessionStatistics

func (*Server) Shutdown

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

func (*Server) Start

func (s *Server) Start() error

Jump to

Keyboard shortcuts

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