From 68d9e03abdf53af1033c1f42fdfeefd1ae691b28 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 31 May 2023 11:03:16 +0800 Subject: [PATCH 1/5] Support to remove and replace controllers Resolve #16706 --- docs/en/API/Auto-API-Controllers.md | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/docs/en/API/Auto-API-Controllers.md b/docs/en/API/Auto-API-Controllers.md index e139c16d20..f4c04115e3 100644 --- a/docs/en/API/Auto-API-Controllers.md +++ b/docs/en/API/Auto-API-Controllers.md @@ -169,3 +169,48 @@ public class PersonAppService : ApplicationService ```` Disabled `IsMetadataEnabled` which hides this service from API explorer and it will not be discoverable. However, it still can be usable for the clients know the exact API path/route. + +## Replace or Remove Controllers. + +In addition to [Overriding a Controller](Customizing-Application-Modules-Overriding-Services#example-overriding-a-controller), you can also use a completely independent **Controller** to replace the controller in the framework or module. + +They have the same [route](https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-7.0), but can have **different** input and output parameters. + +### Replace built-in AbpApplicationLocalizationController + +The `ReplaceControllersAttribute` indicate the replaced controller type. + +````csharp +[ReplaceControllers(typeof(AbpApplicationConfigurationController))] +[Area("abp")] +[RemoteService(Name = "abp")] +public class ReplaceBuiltInController : AbpController +{ + [HttpGet("api/abp/application-configuration")] + public virtual Task GetAsync(MyApplicationConfigurationRequestOptions options) + { + return Task.FromResult(new MyApplicationConfigurationDto()); + } +} + +public class MyApplicationConfigurationRequestOptions : ApplicationConfigurationRequestOptions +{ + +} + +public class MyApplicationConfigurationDto : ApplicationConfigurationDto +{ + +} +```` + +### Remove contoller + +Configure `ControllersToRemove` of `AbpAspNetCoreMvcOptions` to remove the controllers. + +````csharp +services.Configure(options => +{ + options.ControllersToRemove.Add(typeof(AbpLanguagesController)); +}); +```` From 3810518b60a49214b37f4b0d77d80aeae8b9928a Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 31 May 2023 11:05:30 +0800 Subject: [PATCH 2/5] Update Auto-API-Controllers.md --- docs/en/API/Auto-API-Controllers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/API/Auto-API-Controllers.md b/docs/en/API/Auto-API-Controllers.md index f4c04115e3..ef2f54f86d 100644 --- a/docs/en/API/Auto-API-Controllers.md +++ b/docs/en/API/Auto-API-Controllers.md @@ -172,7 +172,7 @@ Disabled `IsMetadataEnabled` which hides this service from API explorer and it w ## Replace or Remove Controllers. -In addition to [Overriding a Controller](Customizing-Application-Modules-Overriding-Services#example-overriding-a-controller), you can also use a completely independent **Controller** to replace the controller in the framework or module. +In addition to [Overriding a Controller](Customizing-Application-Modules-Overriding-Services.md#example-overriding-a-controller), you can also use a completely independent **Controller** to replace the controller in the framework or module. They have the same [route](https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-7.0), but can have **different** input and output parameters. From 7254b747f5d564b21effb94c25f45ec7a8b0f69f Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 31 May 2023 11:06:26 +0800 Subject: [PATCH 3/5] Update Auto-API-Controllers.md --- docs/en/API/Auto-API-Controllers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/API/Auto-API-Controllers.md b/docs/en/API/Auto-API-Controllers.md index ef2f54f86d..6677b0d66d 100644 --- a/docs/en/API/Auto-API-Controllers.md +++ b/docs/en/API/Auto-API-Controllers.md @@ -172,7 +172,7 @@ Disabled `IsMetadataEnabled` which hides this service from API explorer and it w ## Replace or Remove Controllers. -In addition to [Overriding a Controller](Customizing-Application-Modules-Overriding-Services.md#example-overriding-a-controller), you can also use a completely independent **Controller** to replace the controller in the framework or module. +In addition to [Overriding a Controller](../Customizing-Application-Modules-Overriding-Services.md#example-overriding-a-controller), you can also use a completely independent **Controller** to replace the controller in the framework or module. They have the same [route](https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-7.0), but can have **different** input and output parameters. From ad08006b6bdf983f770468b007d732804b8ba05e Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 31 May 2023 16:36:22 +0800 Subject: [PATCH 4/5] Update docs/en/API/Auto-API-Controllers.md Co-authored-by: Qingxiao Ren --- docs/en/API/Auto-API-Controllers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/API/Auto-API-Controllers.md b/docs/en/API/Auto-API-Controllers.md index 6677b0d66d..7eeebe3f51 100644 --- a/docs/en/API/Auto-API-Controllers.md +++ b/docs/en/API/Auto-API-Controllers.md @@ -176,7 +176,7 @@ In addition to [Overriding a Controller](../Customizing-Application-Modules-Over They have the same [route](https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-7.0), but can have **different** input and output parameters. -### Replace built-in AbpApplicationLocalizationController +### Replace built-in AbpApplicationConfigurationController The `ReplaceControllersAttribute` indicate the replaced controller type. From 03da4bd737b213ef8984505bd18a1d8b1427a865 Mon Sep 17 00:00:00 2001 From: Hamza Albreem <94292623+braim23@users.noreply.github.com> Date: Wed, 31 May 2023 13:24:53 +0300 Subject: [PATCH 5/5] Quick Fix for Auto API Controllers Doc --- docs/en/API/Auto-API-Controllers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/API/Auto-API-Controllers.md b/docs/en/API/Auto-API-Controllers.md index 7eeebe3f51..1644e2d28a 100644 --- a/docs/en/API/Auto-API-Controllers.md +++ b/docs/en/API/Auto-API-Controllers.md @@ -178,7 +178,7 @@ They have the same [route](https://learn.microsoft.com/en-us/aspnet/core/mvc/con ### Replace built-in AbpApplicationConfigurationController -The `ReplaceControllersAttribute` indicate the replaced controller type. +The `ReplaceControllersAttribute` indicates the replaced controller type. ````csharp [ReplaceControllers(typeof(AbpApplicationConfigurationController))]