-
Notifications
You must be signed in to change notification settings - Fork 42
Modules
Wicpar edited this page Jan 13, 2020
·
1 revision
Modules are a way to extend behavior of the routing during Initialisation and Runtime.
- A Module type can be instantiated, but two equal instances cannot coexist (a set is used on the backend)
- Modules can be queried by any other module by its class with
ModuleProvider.ofClass<Class>()
- The global module provider can be accessed through an extension or the OpenAPIGen instance with
OpenAPIGen.globalModuleProvider
- The current module provider on a specific route can be accessed through
OpenAPIRoute.provider
(all provided dsl functions properly scope the registered modules, if you implement custom ones make sur you create child handlers usingroute.child().apply { provider.registerModule(YourModule()) }.yourBlockFn()
)
- OpenAPIModule: All modules must implment this interface, it does not have behavior besides indicating intent
- DependentModule: Allows to declare module dependencies from inside a module
- RouteOpenAPIModule: Used to indicate that it is to be used as additional module on one specific route, usually for additional metadata like descriptions, it can only be added explicitly during the final call before the route handle (get post, etc... with the parameters
get<Params, Response>(vararg RouteOpenAPIModule) { ... }
) - HandlerModule: Provides a hook during route creation, used internally to generate the OpenAPI definition
And more, look at the interfaces that implement OpenAPIModule. The module system is used as much as possible internally to allow for maximal extendability.