From 382cbdffce8dcc72ec1f33957337bc8c8c228572 Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Mon, 22 Apr 2024 10:04:46 +0300 Subject: [PATCH] Update Application-Configuration.md --- docs/en/API/Application-Configuration.md | 39 +++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/en/API/Application-Configuration.md b/docs/en/API/Application-Configuration.md index 5f2f2a9c6d..da90831222 100644 --- a/docs/en/API/Application-Configuration.md +++ b/docs/en/API/Application-Configuration.md @@ -1,6 +1,6 @@ # Application Configuration Endpoint -ABP Framework provides a pre-built and standard endpoint that contains some useful information about the application/service. Here, the list of some fundamental information at this endpoint: +ABP Framework provides a pre-built and standard endpoint that contains some useful information about the application/service. Here, is the list of some fundamental information at this endpoint: * Granted [policies](../Authorization.md) (permissions) for the current user. * [Setting](../Settings.md) values for the current user. @@ -22,3 +22,40 @@ See the [JavaScript API document](../UI/AspNetCore/JavaScript-API/Index.md) for Other UI types provide services native to the related platform. For example, see the [Angular UI settings documentation](../UI/Angular/Settings.md) to learn how to use the setting values exposes by this endpoint. +## Extending the Endpoint + +The **application-configuration** endpoint contains some useful information about the application, such as _localization values_, _current user information_, _granted permissions_, etc. Even most of the time these provided values are sufficient to use in your application to perform common requirements such as getting the logged-in user's ID or its granted permissions. You may still want to extend this endpoint and provide additional information for your application/service. At that point, you can use the `IApplicationConfigurationContributor` endpoint. + +### IApplicationConfigurationContributor + +`IApplicationConfigurationContributor` is the interface that should be implemented to add additional information to the **application-configuration** endpoint. + +**Example: Setting the deployment version** + +```csharp +using System.Threading.Tasks; +using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; +using Volo.Abp.Data; + +namespace Acme.BookStore.Web +{ + public class MyApplicationConfigurationContributor : IApplicationConfigurationContributor + { + public Task ContributeAsync(ApplicationConfigurationContributorContext context) + { + //for simplicity, it's a static number, you can inject any service to this class and perform your logic... + var deploymentVersion = "v1.0.0"; + + //setting the deploymentVersion + context.ApplicationConfiguration.SetProperty("deploymentVersion", deploymentVersion); + + return Task.CompletedTask; + } + } +} +``` + +* `IApplicationConfigurationContributor` defines the `ContributeAsync` method to extend the **application-configuration** endpoint with the specified additional data. +* You can inject services and perform any logic needed to extend the endpoint as you wish. + +> Application configuration contributors are automatically discovered by the ABP Framework and executed as a part of the application configuration initialization process.