cmd/searchix-web/generate-error-page.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | package main import ( "os" "github.com/Southclaws/fault" "github.com/Southclaws/fault/fmsg" "alin.ovh/searchix/frontend" "alin.ovh/searchix/internal/components" "alin.ovh/searchix/internal/config" ) type GenerateErrorPageOptions struct{} func (*GenerateErrorPageOptions) Execute(_ []string) error { assets, err := frontend.New() if err != nil { return fault.Wrap(err, fmsg.With("could not create frontend")) } err = components.ErrorTemplate(components.TemplateData{ Source: nil, Sources: []*config.Source{}, Query: "", ExtraHeadHTML: "", Code: 0, Message: `{{placeholder "http.error.status_code"}} {{placeholder "http.error.status_text"}}`, Assets: assets, }).Render(os.Stdout) if err != nil { panic("failed to render error template: " + err.Error()) } return nil } func init() { var opts GenerateErrorPageOptions _, err := parser.AddCommand( "generate-error-page", "generate error page template", "generate error page template for use with a reverse proxy", &opts, ) if err != nil { panic(err) } } |