serve

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package serve starts cover100's local static server and opens the report in the user's browser.

The server is bound to loopback only: the report describes a private codebase, and nothing about viewing it requires exposing it to the network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens url in the platform's default browser. It returns an error only when no launcher could be started; a launcher that starts but fails is the user's environment, not a cover100 failure, so the URL is always printed.

Types

type Options

type Options struct {
	// Assets is a filesystem rooted at the public directory.
	Assets fs.FS
	// DataPath is the absolute path of the report JSON to serve.
	DataPath string
	// DataRoute is the URL path the report is served at, e.g. "/coverage.json".
	DataRoute string
	// Host defaults to 127.0.0.1.
	Host string
	// Port is the preferred port; the server walks forward from it when busy.
	Port int
	// Printer receives the bound URL and diagnostics.
	Printer *ui.Printer
}

Options configures the server.

type Server

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

Server is a running static server.

func Start

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

Start binds the server and returns it ready to Serve. The returned URL is the address the browser should open, including the data query parameter.

func (*Server) Close

func (s *Server) Close() error

Close shuts the server down, waiting for in-flight requests briefly.

func (*Server) PageURL

func (s *Server) PageURL(metric, mode string) string

PageURL returns the viewer page address, with the report URL, metric and mode passed as query parameters so the CLI's defaults and the page's initial state cannot disagree.

func (*Server) Port

func (s *Server) Port() int

Port returns the port the server actually bound.

func (*Server) Serve

func (s *Server) Serve() error

Serve blocks until the server is closed.

func (*Server) URL

func (s *Server) URL() string

URL returns the address of the served report.

Jump to

Keyboard shortcuts

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