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
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.