control

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 15 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 control provides a local control channel for a running kitty-browse process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(ctx context.Context, endpoint string, request json.RawMessage) (json.RawMessage, error)

Action sends an action request through endpoint. A valid JSON response is returned even when its HTTP status indicates an API error, so callers can inspect the API error envelope.

func Capture

func Capture(ctx context.Context, endpoint string, fullPage bool) ([]byte, error)

Capture requests a screenshot through endpoint.

func Info

func Info(ctx context.Context, endpoint string) (json.RawMessage, error)

Info requests browser information through endpoint.

func Quit added in v0.2.2

func Quit(ctx context.Context, endpoint string) error

Quit asks the browser on endpoint to shut down gracefully. The reply is the last document the endpoint serves: the host tears itself down only after the answer has been flushed.

Types

type ActionFunc

type ActionFunc func(context.Context, json.RawMessage) (json.RawMessage, error)

ActionFunc executes a JSON action request and returns its JSON response.

type CaptureFunc

type CaptureFunc func(context.Context, bool) ([]byte, error)

CaptureFunc captures a PNG. fullPage is false for the current viewport and true for the complete page.

type InfoFunc

type InfoFunc func(context.Context) (json.RawMessage, error)

InfoFunc returns the current browser information as JSON.

type Option

type Option func(*serverConfig)

Option configures optional control server functionality.

func WithAPI

func WithAPI(info InfoFunc, action ActionFunc) Option

WithAPI enables the information and action API. A nil callback leaves its corresponding route disabled.

func WithQuit added in v0.2.2

func WithQuit(quit QuitFunc) Option

WithQuit enables the graceful shutdown route. A nil callback leaves /v1/quit disabled, exactly like a nil API callback leaves /v1/actions disabled.

type QuitFunc added in v0.2.2

type QuitFunc func(context.Context)

QuitFunc asks the browser to shut down gracefully. It is called after the quit response has been flushed to the caller, so the answer is never lost to the teardown it triggers.

type Server

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

Server is a screenshot control server.

func Start

func Start(endpoint string, capture CaptureFunc, opts ...Option) (*Server, error)

Start creates the platform-local control endpoint and serves the browser API. On Unix endpoint is an owner-only Unix socket path; on Windows it is a named pipe restricted to the current user.

func (*Server) Close

func (s *Server) Close() error

Close stops the HTTP server and removes the socket created by Start. It is safe to call Close more than once.

Jump to

Keyboard shortcuts

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