pageserver

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 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 pageserver puts the desktop page in front of the service: Proxy forwards the page's API calls to the service's socket (the desktop app's web view and a Server both use it), and a Server serves the page itself to a browser, on a loopback port only whoever holds its link can use.

The service never listens on a network port; a Server does, for the page, so it lets in only requests that carry its cookie, which a one-time link (OpenURL) hands out. Requests must also name the Server's own address as their host (no DNS rebinding) and, when they say where they come from, come from the page (no other site, not even another port on 127.0.0.1, whose requests a browser would send the cookie with).

Index

Constants

View Source
const HostPrefix = "/host/"

HostPrefix is where Options.Host answers: what the page asks of the program serving it (opening folders, the service's controls).

View Source
const TicketTTL = time.Minute

TicketTTL is how long a link from OpenURL lasts unused.

Variables

This section is empty.

Functions

func Proxy

func Proxy(path string) http.Handler

Proxy forwards the page's API requests to the service's Unix socket (a web view can't open one itself), streaming responses as they come. Anything else is not found: the page's own files are served by Wails, or by a Server.

Types

type Options

type Options struct {
	// Page is the page's files, index.html at the root.
	Page fs.FS
	// Socket is the service's socket, for Proxy.
	Socket string
	// Host answers under HostPrefix (nil: not found).
	Host http.Handler
	// Addr is where to listen: 127.0.0.1:0 (any free port) by default.
	// Only a loopback address is allowed.
	Addr string
}

Options are what a Server serves.

type Server

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

Server is the page on a loopback port. Close it when done.

func Start

func Start(o Options) (*Server, error)

Start listens and serves in the background.

func (*Server) Close

func (s *Server) Close() error

Close stops the server.

func (*Server) OpenURL

func (s *Server) OpenURL() string

OpenURL is a link that opens the page once: it lets the browser in (a cookie) and then goes to the page, so the link in the address bar and the history is the page's, not one that would let anyone in again.

func (*Server) Origin

func (s *Server) Origin() string

Origin is the page's origin: http://127.0.0.1:port.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP checks a request and serves it: a link from OpenURL, the API, the host's calls or the page.

Jump to

Keyboard shortcuts

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