webserver

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 20 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 webserver exposes gocrawl over HTTP: an API to start and inspect crawls, backed by the same runner.Run seam the CLI and MCP server use, plus the embedded single-page app (see assets.go) that drives it from a browser.

Index

Constants

View Source
const DefaultMaxRunning = 4

DefaultMaxRunning is the crawl-concurrency cap applied when WithMaxRunning isn't given.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	ID         string
	Seed       string
	Status     Status
	Report     *report.Report
	Err        string
	StartedAt  time.Time
	FinishedAt time.Time
	StoreID    string // set once the report is saved, so history and job views agree on one ID
	// contains filtered or unexported fields
}

Job tracks one in-flight or just-finished crawl started via the web API.

type JobView

type JobView struct {
	ID         string         `json:"id"`
	Seed       string         `json:"seed"`
	Status     string         `json:"status"`
	Err        string         `json:"error,omitempty"`
	StartedAt  string         `json:"started_at,omitempty"`
	FinishedAt string         `json:"finished_at,omitempty"`
	Persisted  bool           `json:"persisted"`
	Report     *report.Report `json:"report,omitempty"`
}

JobView is the API representation of a Job.

type Option added in v0.9.0

type Option func(*Server)

Option configures a Server.

func AllowAnyHost added in v0.9.0

func AllowAnyHost() Option

AllowAnyHost disables the loopback Host-header check. gocrawl serve applies it when the operator deliberately binds to a non-loopback address, at which point the server is reachable from other machines by design and the Host header can legitimately be anything.

func WithMaxRunning added in v0.9.0

func WithMaxRunning(n int) Option

WithMaxRunning caps the number of crawls that may run at once; POST /api/crawls returns 429 once the cap is reached. n <= 0 leaves the default.

type Server

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

Server serves the gocrawl web API and embedded frontend.

func New

func New(st *store.Store, opts ...Option) *Server

New builds a Server backed by st for crawl history (persisted via --save). By default it only answers requests whose Host header is a loopback address and runs at most DefaultMaxRunning crawls at once; see the Option values to change either.

func (*Server) Handler

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

Handler returns the http.Handler serving the API and frontend.

type Status

type Status string

Status is the lifecycle state of a crawl job.

const (
	StatusRunning  Status = "running"
	StatusDone     Status = "done"
	StatusError    Status = "error"
	StatusCanceled Status = "canceled"
)

Jump to

Keyboard shortcuts

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