api

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 18 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

Index

Constants

View Source
const (
	AttachProtocol = "ptyd-attach"
	FrameInput     = 'i'
	FrameResize    = 'r'
)

The attach protocol. A client sends GET /terminals/{id}/attach with "Connection: Upgrade" and "Upgrade: ptyd-attach" (plus the token header), and optionally ?cols=&rows= (its window size) and ?readonly=1. The server answers 101 Switching Protocols (with "X-Ptyd-Readonly: 1" for a read-only attachment, such as a ghost) and the connection carries:

  • server to client: raw terminal output, starting with a repaint of the screen and its scrollback. EOF means the terminal's output ended.
  • client to server: frames of one type byte, a 4-byte big-endian length and a payload. FrameInput carries keystrokes; FrameResize carries cols and rows as two big-endian uint16s.

Variables

This section is empty.

Functions

func AppendFrame

func AppendFrame(b []byte, typ byte, payload []byte) []byte

AppendFrame appends one client frame to b.

Types

type Config

type Config struct {
	Addr  string // host:port to listen on
	Token string // if non-empty, required as X-Ptyd-Token on every request
}

Config holds server-level options.

type Server

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

Server is the HTTP API for ptyd.

func New

func New(mgr *terminal.Manager, cfg Config) *Server

New constructs (but does not start) a Server.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler exposes the wrapped http.Handler (with middleware applied) so tests can drive routes via httptest without binding a real port.

func (*Server) Listen

func (s *Server) Listen() (net.Listener, error)

Listen binds the configured address. Separating this from Serve lets the caller surface bind errors synchronously before logging "listening on …".

func (*Server) Serve

func (s *Server) Serve(ln net.Listener) error

Serve takes over an already-bound listener. Returns nil on graceful shutdown, otherwise the underlying server error.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown stops accepting connections, ends open streams and waits, and waits for in-flight requests to finish (or until ctx expires).

Jump to

Keyboard shortcuts

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