Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Host = &cli.Command{ Name: "host", Usage: "Host the web page content", UsageText: "pages host", Flags: flagset.ExtractPrefix("pages", hostConfig), Action: func(ctx *cli.Context) error { log := zaputil.Extract(ctx.Context) _ = mime.AddExtensionType(".woff2", "application/font-woff2") _ = mime.AddExtensionType(".woff", "application/font-woff") _ = mime.AddExtensionType(".ttf", "font/ttf") _ = mime.AddExtensionType(".yaml", "application/yaml") _ = mime.AddExtensionType(".yml", "application/yaml") _ = mime.AddExtensionType(".json", "application/json") server, err := internal.NewServer(ctx.Context, hostConfig.ServerConfig) if err != nil { return err } endpointConfig := git.EndpointConfig{ Sites: make(map[string]*git.Config), } if hostConfig.SiteFile == "" { endpointConfig.Sites["*"] = &hostConfig.Git } else { err = config.Load(ctx.Context, &endpointConfig, hostConfig.SiteFile) if err != nil { return err } } endpoint, err := git.NewEndpoint(ctx.Context, endpointConfig) if err != nil { return err } defer endpoint.Close() { server.AdminMux.HandleFunc("/sync", endpoint.Sync).Methods(http.MethodPost) server.PublicMux.PathPrefix("/").HandlerFunc(endpoint.Lookup).Methods(http.MethodGet) } log.Info("serving", zap.String("public", hostConfig.Public.Address), zap.String("private", hostConfig.Private.Address)) group, c := errgroup.WithContext(ctx.Context) group.Go(server.ListenAndServe) group.Go(func() error { return endpoint.SyncLoop(ctx.Context) }) <-c.Done() shutdownTimeout := 30 * time.Second timeout, cancelTimeout := context.WithTimeout(context.Background(), shutdownTimeout) defer cancelTimeout() _ = server.Shutdown(timeout) _ = group.Wait() err = c.Err() if err != context.Canceled { return err } return nil }, HideHelpCommand: true, } )
View Source
var Version = &cli.Command{ Name: "version", Usage: "Print the binary version information", UsageText: "pages version", Action: func(ctx *cli.Context) error { return template. Must(template.New("version").Parse(versionTemplate)). Execute(ctx.App.Writer, ctx.App) }, HideHelpCommand: true, }
Functions ¶
This section is empty.
Types ¶
type HostConfig ¶
type HostConfig struct { internal.ServerConfig Git git.Config `json:"git"` SiteFile string `json:"site_file" usage:"configure multiple sites using a single file"` }
Click to show internal directories.
Click to hide internal directories.