This page describes how to integrate Extension Manager functionality into another Go application.
You can embed the Extension Manager's REST API in another Go application that uses the Nightapes/go-rest library:
// Create an instance of `openapi.API`
api := openapi.NewOpenAPI()
// Create a new configuration
config := extensionController.ExtensionManagerConfig{
ExtensionRegistryURL: "https://example.com/registry.json",
BucketFSBasePath: "/buckets/bfsdefault/default/",
ExtensionSchema: "EXA_EXTENSIONS",
}
// Add endpoints
err := restAPI.AddPublicEndpoints(api, config)
if err != nil {
return err
}
// Start the server
If you want to directly use the extension controller in your Go application you can use the following code as an example:
// Create a new configuration
config := extensionController.ExtensionManagerConfig{
ExtensionRegistryURL: "https://example.com/registry.json",
BucketFSBasePath: "/buckets/bfsdefault/default/",
ExtensionSchema: "EXA_EXTENSIONS",
}
// Create controller and handle configuration validation error
ctrl, err := extensionController.CreateWithValidatedConfig(config)
if err != nil {
return err
}
// Create database connection (required as an argument for all controller methods)
var db *sql.DB = createDBConnection()
// Call controller method and process result. Use a custom context if available.
extensions, err := ctrl.GetAllExtensions(context.Background(), db)
// ...