server

package
v2.6.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const CacheControlFlagName = "cache-control"

CacheControlFlagName is the CLI flag name for setting the Cache-Control max-age TTL.

View Source
const HealthChecksFlagName = "health-checks"

HealthChecksFlagName is the CLI flag name for enabling health-check endpoints.

View Source
const HostFlagName = "host"

HostFlagName is the CLI flag name for setting the HTTP bind address.

View Source
const InputPostsDirArgName = "input-posts"

InputPostsDirArgName is the CLI argument name for the input posts directory.

View Source
const PortFlagName = "port"

PortFlagName is the CLI flag name for setting the HTTP listen port.

View Source
const WatchFlagName = "watch"

WatchFlagName is the CLI flag name for enabling filesystem watching.

Variables

View Source
var ServeCommand cli.Command = cli.Command{
	Name:                   "serve",
	Aliases:                []string{"s"},
	Usage:                  "serve a blog from markdown posts over HTTP",
	Action:                 NewServeCommand,
	UseShortOptionHandling: true,
	Arguments: []cli.Argument{
		&cli.StringArg{
			Name:      InputPostsDirArgName,
			UsageText: "<input directory>",
		},
	},
	Flags: []cli.Flag{
		&cli.IntFlag{
			Name:    PortFlagName,
			Aliases: []string{"P"},
			Usage:   "port to listen on",
			Value:   8080,
		},
		&cli.StringFlag{
			Name:    HostFlagName,
			Aliases: []string{"H"},
			Usage:   "host address to bind to",
		},
		&cli.BoolFlag{
			Name:    WatchFlagName,
			Aliases: []string{"w"},
			Usage:   "watch the posts directory and regenerate the blog on changes",
			Value:   false,
		},
		&cli.DurationFlag{
			Name:  CacheControlFlagName,
			Usage: "max-age TTL for the Cache-Control header (0 disables the header)",
			Value: time.Hour,
		},
		&cli.BoolFlag{
			Name:  HealthChecksFlagName,
			Usage: "expose /healthz/live, /healthz/ready, and /healthz/startup endpoints (no auth required); the server binds before loading content so probes observe startup state",
			Value: false,
		},
	},
}

ServeCommand is the main entry point for the GoBlog serve CLI tool. This command sets up all the flags, usage info, and action for serve.

Functions

func NewServeCommand added in v2.1.0

func NewServeCommand(ctx context.Context, c *cli.Command) error

NewServeCommand handles the serve command by starting an HTTP server from a directory of markdown posts.

Types

This section is empty.

Jump to

Keyboard shortcuts

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