This documentation is for a release that is no longer maintained
See documentation for the latest supported version.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 10. Overriding Core Backend Service Configuration
The Red Hat Developer Hub (RHDH) backend platform consists of a number of core services that are well encapsulated. The RHDH backend installs these default core services statically during initialization.
You can configure these core services by customizing the backend source code and rebuilding your Developer Hub application. Alternatively, you can customize a core service by installing it as a BackendFeature
by using dynamic plugin functionality.
To use the dynamic plugin functionality to customize a core service in your RHDH application, you must configure the backend to avoid statically installing a given default core service.
For example, adding a middleware function to handle all incoming requests can be done by installing a custom configure
function for the root HTTP
router backend service which allows access to the underlying Express application.
Example of a BackendFeature
middleware function to handle incoming HTTP
requests
// Create the BackendFeature export const customRootHttpServerFactory: BackendFeature = rootHttpRouterServiceFactory({ configure: ({ app, routes, middleware, logger }) => { logger.info( 'Using custom root HttpRouterServiceFactory configure function', ); app.use(middleware.helmet()); app.use(middleware.cors()); app.use(middleware.compression()); app.use(middleware.logging()); // Add a the custom middleware function before all // of the route handlers app.use(addTestHeaderMiddleware({ logger })); app.use(routes); app.use(middleware.notFound()); app.use(middleware.error()); }, }); // Export the BackendFeature as the default entrypoint export default customRootHttpServerFactory;
// Create the BackendFeature
export const customRootHttpServerFactory: BackendFeature =
rootHttpRouterServiceFactory({
configure: ({ app, routes, middleware, logger }) => {
logger.info(
'Using custom root HttpRouterServiceFactory configure function',
);
app.use(middleware.helmet());
app.use(middleware.cors());
app.use(middleware.compression());
app.use(middleware.logging());
// Add a the custom middleware function before all
// of the route handlers
app.use(addTestHeaderMiddleware({ logger }));
app.use(routes);
app.use(middleware.notFound());
app.use(middleware.error());
},
});
// Export the BackendFeature as the default entrypoint
export default customRootHttpServerFactory;
In the above example, as the BackendFeature
overrides the default implementation of the HTTP router service, you must set the ENABLE_CORE_ROOTHTTPROUTER_OVERRIDE
environment variable to true
so that the Developer Hub does not install the default implementation automatically.
10.1. Overriding environment variables
To allow a dynamic plugin to load a core service override, you must start the Developer Hub backend with the corresponding core service ID environment variable set to true
.
Variable | Description |
---|---|
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |
|
Override the |