type Server … type vcsHandler … type scriptResult … // NewServer returns a Server that generates and serves repositories in workDir // using the scripts found in scriptDir and its subdirectories. // // A request for the path /foo/bar/baz will be handled by the first script along // that path that exists: $scriptDir/foo.txt, $scriptDir/foo/bar.txt, or // $scriptDir/foo/bar/baz.txt. func NewServer(scriptDir, workDir string, logger *log.Logger) (*Server, error) { … } func (s *Server) Close() error { … } var gitConfig … var hgrc … // ServeHTTP implements [http.Handler] for version-control repositories. func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { … } type ScriptNotFoundError … func (e ScriptNotFoundError) Error() string { … } func (e ScriptNotFoundError) Unwrap() error { … } type ServerNotInstalledError … func (v ServerNotInstalledError) Error() string { … } // HandleScript ensures that the script at scriptRelPath has been evaluated // with its current contents. // // If the script completed successfully, HandleScript invokes f on the handler // with the script's result still read-locked, and waits for it to return. (That // ensures that cache invalidation does not race with an in-flight handler.) // // Otherwise, HandleScript returns the (cached) error from executing the script. func (s *Server) HandleScript(scriptRelPath string, logger *log.Logger, f func(http.Handler)) error { … } // overview serves an HTML summary of the status of the scripts in the server's // script directory. func (s *Server) overview(w http.ResponseWriter, r *http.Request) { … } // help serves a plain-text summary of the server's supported script language. func (s *Server) help(w http.ResponseWriter, req *http.Request) { … }