Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the DisableAbpFeatures. #18638

Merged
merged 4 commits into from Jan 28, 2024
Merged

Introduce the DisableAbpFeatures. #18638

merged 4 commits into from Jan 28, 2024

Conversation

maliming
Copy link
Member

@maliming maliming commented Dec 30, 2023

Resolve #18635

If you have some APIs, they are used frequently, but you don't need all the features of abp.

[Route("api/my-high-concurrency-api")]
[DisableAbpFeatures]
public class NoContentTestController : AbpController
{

}
[AttributeUsage(AttributeTargets.Class)]
public class DisableAbpFeaturesAttribute : Attribute
{
    /// <summary>
    /// The framework will not register any interceptors for the class.
    /// This will cause the all features that depend on interceptors to not work.
    /// </summary>
    public bool DisableInterceptors { get; set; } = true;

    /// <summary>
    /// The framework middleware will skip the class.
    /// This will cause the all features that depend on middleware to not work.
    /// </summary>
    public bool DisableMiddleware { get; set; } = true;

    /// <summary>
    /// The framework will not remove all built-in filters for the class.
    /// This will cause the all features that depend on filters to not work.
    /// </summary>
    public bool DisableMvcFilters { get; set; } = true;
}

@maliming maliming added this to the 8.1-preview milestone Dec 30, 2023
@maliming maliming marked this pull request as ready for review December 30, 2023 13:47

This comment was marked as resolved.

@maliming maliming marked this pull request as draft December 31, 2023 03:55
@maliming maliming marked this pull request as ready for review January 1, 2024 08:51
@maliming maliming changed the title Provide a way for the controller to skip all interceptors and filters. Introduce the DisableAbpFeatures. Jan 1, 2024
@ebicoglu
Copy link
Member

ebicoglu commented Jan 1, 2024

when it's on, multi-tenancy, input validation, localization, transaction management (UOW) and other features will be disabled?

@maliming
Copy link
Member Author

maliming commented Jan 1, 2024

when it's on, multi-tenancy, input validation, localization, transaction management (UOW) and other features will be disabled?

Yes, This is not commonly used, but if you have a controller that just has some simple logic, disabling these features will increase its performance.

@ebicoglu
Copy link
Member

ebicoglu commented Jan 2, 2024

  • It is available for only classes. It may be good if it covers methods as well AttributeUsage(AttributeTargets.Method).
  • Is it different than deriving from ASP.NET Core's default Controller?
public class NoContentTestController : AbpController
public class NoContentTestController : Controller

@maliming
Copy link
Member Author

maliming commented Jan 2, 2024

  1. It cannot be disabled at the method level because interceptors and global filters target a class.
  2. AbpController contains many commonly used services. There is no difference in other conveniences because its base class is Controller.

@maliming maliming requested a review from hikalkan January 4, 2024 02:27
@hikalkan hikalkan merged commit 4400d0d into dev Jan 28, 2024
7 checks passed
@hikalkan hikalkan deleted the DisableInterceptorAndFilter branch January 28, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a way for the controller to skip all interceptors and filters.
3 participants