Documentation
¶
Index ¶
- Constants
- func HostValidationMiddleware(next http.Handler, port int) http.Handler
- func SeqPath(store *versions.Store) string
- func ValidateHost(r *http.Request, port int) bool
- func ValidatePath(relPath string, homeDir string) (string, error)
- type LiveSync
- type Server
- func (s *Server) Close() error
- func (s *Server) SetConfirm(fn func(title, message string) (platform.ConfirmChoice, error))
- func (s *Server) SetInternalDir(dir string)
- func (s *Server) SetSiteLabel(label string)
- func (s *Server) SetTrustFolder(fn func(dir string) error)
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Start() error
Constants ¶
const ShutdownBudget = 3 * time.Second
ShutdownBudget is how long graceful shutdown may take. main.go uses it for its shutdown context, and sseWriteDeadline is defined strictly under it, so the two cannot drift apart into a shutdown that always force-closes.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LiveSync ¶ added in v1.2.0
type LiveSync struct {
// contains filtered or unexported fields
}
LiveSync bundles the process-wide live-sync machinery: the pub/sub hub, the file watcher, and the coordinator that keeps their membership in step. One LiveSync is shared by every per-tree site. It keys all state by absolute file path, and absolute paths are unique across the single home directory, so sharing one instance never collides between sites.
func NewLiveSync ¶ added in v1.2.0
NewLiveSync builds the shared live-sync runtime. seqPath is the persisted sequence high-water mark, which lives beside the backups in a private 0700 directory the server refuses to serve.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func New ¶
func New(ln net.Listener, sessions *session.Manager, logger *logging.Logger, store *versions.Store) *Server
New builds a server that owns its own live-sync runtime and tears it down on Shutdown/Close. Used by tests and any single-server caller.
func NewWithLiveSync ¶ added in v1.2.0
func NewWithLiveSync(ln net.Listener, sessions *session.Manager, logger *logging.Logger, store *versions.Store, ls *LiveSync) *Server
NewWithLiveSync builds a server that shares an injected live-sync runtime with its sibling sites. The runtime is owned by the process, not by any one server, so Shutdown/Close leave it running; the process shuts it down once.
func (*Server) SetConfirm ¶ added in v1.2.0
func (s *Server) SetConfirm(fn func(title, message string) (platform.ConfirmChoice, error))
SetConfirm replaces the permission prompt. Production uses the native dialog; tests inject a deterministic decision so no real dialog is ever shown.
func (*Server) SetInternalDir ¶ added in v1.2.0
SetInternalDir marks a directory the server must never serve, whatever the read roots say. htmlclay's own config tree holds its log and settings, and a grant that happens to cover that directory must not turn into a read path. Denying on the serve path is structural; a grant-time guard can only ever cover the grants it happens to see.
func (*Server) SetSiteLabel ¶ added in v1.2.0
SetSiteLabel names this site in the permission dialog so the user knows which page is asking. Optional; the broker falls back to a generic label.
func (*Server) SetTrustFolder ¶ added in v1.2.0
SetTrustFolder wires the durable half of the permission dialog's "Trust this folder" choice. Optional: with no hook the choice still installs the session read root, so the page works and the folder simply asks again next launch.
func (*Server) Shutdown ¶
Shutdown releases parked permission requests and closes every SSE stream before handing off to http.Server.Shutdown. Both otherwise hold graceful shutdown open until its timeout and are then force-closed. A server that shares an injected live-sync runtime leaves it running (the process shuts the shared runtime down once, before the per-site HTTP servers).