Documentation ¶
Overview ¶
Package serve provides a way to create and manage an HTTP server, including routing, middleware, and graceful shutdown.
Index ¶
- type DataFunc
- type Server
- func (s *Server) BackgroundTask(r *http.Request, fn func() error)
- func (s *Server) Config() *conf.HopConfig
- func (s *Server) Logger() *slog.Logger
- func (s *Server) OnShutdown(fn func(context.Context) error)
- func (s *Server) ReportServerError(r *http.Request, err error)
- func (s *Server) Router() *route.Mux
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Start() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataFunc ¶
DataFunc is a function type that takes an HTTP request and a pointer to a map of data. It represents a callback function that can be used to populate data for templates.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) BackgroundTask ¶
BackgroundTask runs a function in a goroutine, and reports any errors to the server's error logger.
func (*Server) OnShutdown ¶ added in v0.0.18
OnShutdown registers a shutdown handler to be called before the server stops
func (*Server) ReportServerError ¶
ReportServerError logs the error and sends an email to the admin
Click to show internal directories.
Click to hide internal directories.