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 ¶
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
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.