()
| 49 | } |
| 50 | |
| 51 | func (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 | |
| 78 | func (widget *customAPIWidget) update(ctx context.Context) { |
| 79 | compiledHTML, err := fetchAndRenderCustomAPIRequest( |
nothing calls this directly
no test coverage detected