Documentation
¶
Index ¶
- func Run(ctx context.Context, srv *Server, addr string) error
- type Option
- func WithBus(b *eventbus.Bus) Option
- func WithConfig(cfg *config.RuntimeConfig) Option
- func WithConfigFile(path string) Option
- func WithDB(db *sql.DB) Option
- func WithDBRegistry(r *dbdrivers.Registry) Option
- func WithDLQRegistry(r *dlq.Registry) Option
- func WithEmailRegistry(r *email.Registry) Option
- func WithFeedSignKey(key string) Option
- func WithHandler(h http.Handler) Option
- func WithImageSignKey(key string) Option
- func WithLinkSignKey(key string) Option
- func WithNavRegistry(n *nav.Registry) Option
- func WithQuerier(q db.Querier) Option
- func WithRouterRegistry(r *router.Registry) Option
- func WithSessionManager(sm common.SessionManager) Option
- func WithShareSignKey(key string) Option
- func WithStore(store *sessions.CookieStore) Option
- func WithTasksRegistry(r *tasks.Registry) Option
- func WithWebsocket(w *websocket.Module) Option
- type Server
- func (s *Server) Addr() string
- func (s *Server) Close()
- func (s *Server) CoreDataMiddleware() func(http.Handler) http.Handler
- func (s *Server) GetCoreData(w http.ResponseWriter, r *http.Request) (*common.CoreData, *http.Request)
- func (s *Server) RunContext(ctx context.Context) error
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Start(addr string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*Server)
Option configures the Server returned by New.
func WithConfig ¶
func WithConfig(cfg *config.RuntimeConfig) Option
WithConfig supplies the runtime configuration.
func WithConfigFile ¶
WithConfigFile sets the config file path.
func WithDBRegistry ¶
WithDBRegistry sets the database driver registry.
func WithDLQRegistry ¶
WithDLQRegistry sets the dead letter queue registry.
func WithEmailRegistry ¶
WithEmailRegistry sets the email provider registry.
func WithFeedSignKey ¶
WithFeedSignKey sets the feed signing key.
func WithHandler ¶
WithHandler sets the HTTP handler used by the server.
func WithImageSignKey ¶
WithImageSignKey sets the image signing key.
func WithLinkSignKey ¶
WithLinkSignKey sets the external link signing key.
func WithNavRegistry ¶
WithNavRegistry sets the navigation registry.
func WithQuerier ¶
WithQuerier sets a custom query implementation for the server.
func WithRouterRegistry ¶
WithRouterRegistry sets the router registry.
func WithSessionManager ¶
func WithSessionManager(sm common.SessionManager) Option
WithSessionManager sets the session manager used by the server.
func WithShareSignKey ¶
WithShareSignKey sets the share signing key.
func WithStore ¶
func WithStore(store *sessions.CookieStore) Option
WithStore sets the session store used by the server.
func WithTasksRegistry ¶
WithTasksRegistry sets the tasks registry used by the server.
func WithWebsocket ¶
WithWebsocket sets the websocket module.
type Server ¶
type Server struct {
RouterReg *router.Registry
Config *config.RuntimeConfig
ConfigFile string
Router http.Handler
NotFoundHandler http.Handler
Store *sessions.CookieStore
DB *sql.DB
Queries db.Querier
Bus *eventbus.Bus
EmailReg *email.Registry
// Signing keys (simple strings, no complex objects)
FeedSignKey string
ImageSignKey string
LinkSignKey string
SessionManager common.SessionManager
TasksReg *tasks.Registry
DBReg *dbdrivers.Registry
DLQReg *dlq.Registry
Websocket *websocket.Module
LanguageCache *common.LanguageCache
WorkerCancel context.CancelFunc
// contains filtered or unexported fields
}
Server bundles the application's configuration, router and runtime dependencies.
func (*Server) Close ¶
func (s *Server) Close()
Close releases resources associated with the server such as background workers, the event bus and the database connection.
func (*Server) CoreDataMiddleware ¶
func (*Server) GetCoreData ¶
func (s *Server) GetCoreData(w http.ResponseWriter, r *http.Request) (*common.CoreData, *http.Request)
CoreDataMiddleware constructs the middleware responsible for populating CoreData in the request context using the server's configured dependencies.
func (*Server) RunContext ¶
RunContext starts the server using the configured HTTPListen address.