Skip to main content

How to create a custom REST service in an Atoti Server Extension

note

You can find all the necessary information on Spring REST services in the Spring documentation.

In this guide, we show the steps required to create a custom REST service in an Atoti Server Extension.

1. Create a custom REST service

Since Atoti Server Extension is a Spring Boot application, you can create a custom REST service by creating a Spring @RestController class.

/** A REST controller that exposes cube information. */
@RestController
@RequestMapping("/app-extension")
@RequiredArgsConstructor
public class AtotiServerExtensionRestController {
/** These Beans are available with the atoti-server-runtime-extension module. */
private final IActivePivotManager activePivotManager;
private final IDatastore datastore;
@GetMapping("/cubes")
public ResponseEntity<String> getCubes() {
final String cubes = String.join(",", activePivotManager.getActivePivots().keySet());
return ResponseEntity.of(Optional.of(cubes));
}
}

2. Register the REST service

To register your custom REST service, you need to import it in your main spring @AutoConfiguration class.

/* Autoconfiguration for the Atoti Server Extension. */
@AutoConfiguration
@Import({AtotiServerExtensionRestController.class})
public class AtotiServerExtensionAutoConfiguration {}