server

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 21 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)"`
	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)"`
	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) GetMainDatabase added in v0.2.4

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

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) Logger

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

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) Router added in v0.2.2

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

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