MCPcopy Create free account
hub / github.com/gotenberg/gotenberg / Module

Method Module

pkg/gotenberg/context.go:48–59  ·  view source on GitHub ↗

Module returns a module which satisfies the requested interface. func (m *YourModule) Provision(ctx *gotenberg.Context) error { mod, _ := ctx.Module(new(ModuleInterface)) real := mod.(ModuleInterface) } If the module has not yet been initialized, this method initializes it. Otherwise, return

(kind any)

Source from the content-addressed store, hash-verified

46// If the module has not yet been initialized, this method
47// initializes it. Otherwise, returns the already initialized instance.
48func (ctx *Context) Module(kind any) (any, error) {
49 mods, err := ctx.Modules(kind)
50 if err != nil {
51 return nil, fmt.Errorf("get module: %w", err)
52 }
53
54 if len(mods) != 1 {
55 return nil, fmt.Errorf("expected to have one and only one %s module", kind)
56 }
57
58 return mods[0], nil
59}
60
61// Modules return the list of modules which satisfies the requested interface.
62//

Callers 4

TestContext_ModuleFunction · 0.95
ProvisionMethod · 0.80
ProvisionMethod · 0.80
ProvisionMethod · 0.80

Calls 1

ModulesMethod · 0.95

Tested by 1

TestContext_ModuleFunction · 0.76