Browse Source

Merge pull request #19595 from abpframework/EngincanV-patch-1

Document "how to extend the application-configuration endpoint"
pull/19596/head
maliming 2 years ago
committed by GitHub
parent
commit
83905f1563
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 39
      docs/en/API/Application-Configuration.md

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

Loading…
Cancel
Save