BuiltinController

Base class for built-in controllers provided by Elide.

"Built-in" controllers are mounted within the application context by default, and handle events like global 404 Not Found and upstream call failures.

Built-in controllers

Each built-in controller operates at the default @Singleton scope, and complies with StatusEnabledController. As such, state tied to individual requests is not allowed on built-in controllers unless proper synchronization is used.

Users can replace built-in controllers via Micronaut annotations. See below for more.

Overriding built-in controllers

To override a built-in controller, implement BaseController and annotate your class as follows:

@Controller
@Replaces(SomeBuiltinController::class)
class MyController {
// ...
}

Default built-in controllers

The following built-in controllers are provided by the framework by default:

Low-level error handler

General/low-level error handling is provided at the executor level by UncaughtExceptionHandler, which can also be customized / replaced via the same mechanism shown above. See docs on that class for more info.

See also

for the built-in controller which handles 404 Not Found events.

for the built-in controller which handles generic internal error events.

for customizable background error handling logic.

Inheritors

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
Link copied to clipboard
suspend fun PageController.asset(request: HttpRequest<*>, type: AssetType? = null, block: suspend AssetHandler.() -> Unit): FinalizedAssetResponse

Generate a StreamedAssetResponse which serves an asset embedded within the application, and specified by the provided block; request will be considered when producing the response.

suspend fun PageController.asset(request: HttpRequest<*>, moduleId: AssetModuleId, type: AssetType? = null): FinalizedAssetResponse

Serve an application asset file which is embedded in the application JAR as a registered server asset, from the application resource path /assets.

Link copied to clipboard
open override fun assets(): AssetManager
Link copied to clipboard
open override fun context(): ApplicationContext
Link copied to clipboard
abstract suspend fun handle(request: HttpRequest<out Any>): RawResponse

Handles a request to this built-in controller.

Link copied to clipboard
suspend fun PageController.html(block: suspend HTML.() -> Unit): RawResponse

Responds to a client with an HTML response, using specified block to build an HTML page via Kotlin's HTML DSL.

Link copied to clipboard
suspend fun PageController.script(request: HttpRequest<*>, block: AssetHandler.() -> Unit): FinalizedAssetResponse

Serve a static script asset embedded within the application, based on the provided block, which should customize the serving of the script and declare a module ID.

suspend fun PageController.script(request: HttpRequest<*>, moduleId: AssetModuleId): FinalizedAssetResponse

Serve a static script asset embedded within the application, based on the provided moduleId, and customizing the response based on the provided request.

Link copied to clipboard
suspend fun PageController.stylesheet(request: HttpRequest<*>, block: AssetHandler.() -> Unit): FinalizedAssetResponse

Serve a static stylesheet asset embedded within the application, based on the provided block, which should customize the serving of the document and declare a module ID.

suspend fun PageController.stylesheet(request: HttpRequest<*>, moduleId: AssetModuleId): FinalizedAssetResponse

Serve a static stylesheet asset embedded within the application, based on the provided moduleId, and customizing the response based on the provided request.