Documentation
¶
Overview ¶
Package preview serves a session's checkout, and its artifact directory, over loopback HTTP, so the session's browser can load a local file without a file: URL. A file: page follows its own links to any path on the machine, and the Chromium that loads it runs outside a confined session's sandbox; it also gets a null origin, which blocks module scripts and fetch. Served from an os.Root, the directory is the whole of what the page can reach.
Index ¶
- func IsLocal(raw string) bool
- type Service
- func (s *Service) ArtifactURL(dir string, devPort int, raw string) (string, bool, error)
- func (s *Service) Close() error
- func (s *Service) IsNewTab(raw string) bool
- func (s *Service) NewTabURL(session string) (string, error)
- func (s *Service) SetNewTab(h http.Handler)
- func (s *Service) URL(dir string, devPort int, raw string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds one listener per served directory, opened the first time a page from it is asked for and kept until Close.
func (*Service) ArtifactURL ¶ added in v0.88.0
ArtifactURL is the http URL that serves raw when it names a file in dir, a session's artifact directory (internal/artifact), and ok is false when it does not, which leaves raw to the checkout. devPort is the session's dev-server port, 0 without one; it only places the listener.
func (*Service) IsNewTab ¶
IsNewTab reports whether raw is a new-tab page of this lich: its own origin, not any page of the machine that happens to share the path.
func (*Service) NewTabURL ¶
NewTabURL is the http URL of session's new-tab page. One listener of its own serves every session's: a page the agent wrote, from an artifact's origin, then cannot fetch the project's services and recent pages. The session is in the path, and the handler answers 404 for one it does not know.