Documentation
¶
Overview ¶
Package devserver implements Margo's development-only site server.
Index ¶
- func Listen(host string, port int, explicit bool, listen ListenFunc) (net.Listener, int, error)
- func NewHandler(store *SnapshotStore, broker *Broker) http.Handler
- func Run(ctx context.Context, options Options) error
- func URL(host string, port int, basePath string) string
- type Broker
- type BuildEvent
- type Builder
- type ChangeSource
- type ListenFunc
- type Options
- type Snapshot
- type SnapshotStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
func NewHandler(store *SnapshotStore, broker *Broker) http.Handler
NewHandler serves the current in-memory snapshot and live-reload stream.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker publishes successful build generations to connected browsers.
type BuildEvent ¶
BuildEvent reports one completed development build.
type ChangeSource ¶
ChangeSource emits debounced filesystem changes and watcher failures.
type ListenFunc ¶
ListenFunc opens one network listener.
type Options ¶
type Options struct {
Listener net.Listener
URL string
Builder Builder
Changes ChangeSource
Store *SnapshotStore
Broker *Broker
Started func(string)
BuildReported func(BuildEvent)
}
Options configures one development server run.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is one immutable, HTTP-ready site build.
func NewSnapshot ¶
NewSnapshot copies a site result into an immutable serving snapshot.
func (Snapshot) ArtifactCount ¶
ArtifactCount returns the number of generated artifacts.
type SnapshotStore ¶
type SnapshotStore struct {
// contains filtered or unexported fields
}
SnapshotStore atomically exposes the last successful site build.
func NewSnapshotStore ¶
func NewSnapshotStore() *SnapshotStore
NewSnapshotStore creates an empty serving store.
func (*SnapshotStore) Replace ¶
func (store *SnapshotStore) Replace(snapshot Snapshot) uint64
Replace publishes a successful snapshot and returns its new generation.
func (*SnapshotStore) SetError ¶
func (store *SnapshotStore) SetError(failure error)
SetError records a failed build without discarding a last-good snapshot.