preview

package
v0.82.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package preview serves a session's checkout 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 checkout is the whole of what the page can reach.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLocal

func IsLocal(raw string) bool

IsLocal reports whether raw names a local file, as a file: URL or an absolute path, rather than a URL the browser loads as is.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service holds one listener per checkout, opened the first time a page from it is asked for and kept until Close.

func New

func New() *Service

New returns a Service that binds the loopback interface.

func (*Service) Close

func (s *Service) Close() error

Close stops every checkout's listener.

func (*Service) URL

func (s *Service) URL(dir string, devPort int, raw string) (string, error)

URL is the http URL that serves raw, a file: URL or an absolute path inside dir, from the checkout at dir whose dev-server port is devPort.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL