server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package server implements the ditto HTTP API server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server wraps net/http and exposes the ditto copy lifecycle over HTTP.

func New

func New(addr string, client copypkg.CopyClient, token string, statusFn func() StatusResponse) *Server

New creates a Server. addr is a listen address like ":8080". token is the expected Bearer token; pass "" to disable auth. statusFn is called by GET /v1/status to produce operational metrics.

func (*Server) Start

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

Start begins listening and blocks until ctx is cancelled, then shuts down with a 15-second grace period.

type StatusResponse

type StatusResponse struct {
	Version      string `json:"version"`
	ActiveCopies int    `json:"active_copies"`
	WarmCopies   int    `json:"warm_copies"`
	PortPoolFree int    `json:"port_pool_free"`
}

StatusResponse is the payload returned by GET /v1/status.

Jump to

Keyboard shortcuts

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