MCPcopy
hub / github.com/glanceapp/glance / initialize

Method initialize

internal/glance/widget-custom-api.go:51–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49}
50
51func (widget *customAPIWidget) initialize() error {
52 widget.withTitle("Custom API").withCacheDuration(1 * time.Hour)
53
54 if err := widget.CustomAPIRequest.initialize(); err != nil {
55 return fmt.Errorf("initializing primary request: %v", err)
56 }
57
58 for key := range widget.Subrequests {
59 if err := widget.Subrequests[key].initialize(); err != nil {
60 return fmt.Errorf("initializing subrequest %q: %v", key, err)
61 }
62 }
63
64 if widget.Template == "" {
65 return errors.New("template is required")
66 }
67
68 compiledTemplate, err := template.New("").Funcs(customAPITemplateFuncs).Parse(widget.Template)
69 if err != nil {
70 return fmt.Errorf("parsing template: %w", err)
71 }
72
73 widget.compiledTemplate = compiledTemplate
74
75 return nil
76}
77
78func (widget *customAPIWidget) update(ctx context.Context) {
79 compiledHTML, err := fetchAndRenderCustomAPIRequest(

Callers

nothing calls this directly

Calls 3

withCacheDurationMethod · 0.80
withTitleMethod · 0.80
initializeMethod · 0.65

Tested by

no test coverage detected