server

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 27 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: '')"`
	LoginMode               string          `comment:"Login mode: none, db, gotrue (default: none)"`
	AuthURL                 string          `comment:"URL of the external AuthN service (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)"`
	GracefulShutdownTimeout int64           `comment:"The maximum duration (seconds) to wait for in-flight requests to complete on shutdown (default: 0, wait until done)"`
	DrainDelay              int64           `` /* 183-byte string literal not displayed */
	TokenExpiry             int64           `comment:"JWT token expiry in seconds (default: 86400 = 24h, 0 for no expiry)"`
	VerboseErrors           bool            `comment:"Return full database error details (hint, detail) to clients (default: true)"`
	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"`
	JQ                      jqeval.Config   `comment:"jq evaluation 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) IsDraining added in v0.8.2

func (s *Server) IsDraining() bool

IsDraining reports whether a graceful shutdown has begun

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)

Shutdown stops the server gracefully, waiting for in-flight requests within ctx's deadline. It is idempotent: the signal path installed by Run and an embedder may both call it.

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