server

package
v2.6.0-beta2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const BlogRootFlagName = "root-path"

BlogRootFlagName is the CLI flag name for setting a blog root path.

View Source
const CacheControlFlagName = "cache-control"

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

View Source
const DisableReadingTimeFlagName = "disable-reading-time"

DisableReadingTimeFlagName is the CLI flag name for disabling reading time estimation.

View Source
const DisableTagsFlagName = "disable-tags"

DisableTagsFlagName is the CLI flag name for disabling tag page generation.

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 TemplateDirFlagName = "template-dir"

TemplateDirFlagName is the CLI flag name for setting a template directory.

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.StringFlag{
			Name:    TemplateDirFlagName,
			Aliases: []string{"t"},
			Usage:   "directory of templates to use when rendering",
		},
		&cli.StringFlag{
			Name:    BlogRootFlagName,
			Aliases: []string{"p"},
			Usage:   "root path of the blog, defaults to '/'",
			Value:   "/",
		},
		&cli.BoolFlag{
			Name:    DisableTagsFlagName,
			Aliases: []string{"T"},
			Usage:   "disable tag tracking and tag page generation",
			Value:   false,
		},
		&cli.BoolFlag{
			Name:  DisableReadingTimeFlagName,
			Usage: "disable reading time estimation on posts",
			Value: false,
		},
		&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