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

feat: support match and ignore property with array #2805

Merged
merged 1 commit into from
Mar 25, 2023

Conversation

czy88840616
Copy link
Member

@czy88840616 czy88840616 commented Mar 19, 2023

支持中间件的 match /ignore 属性写为字符串,正则,函数回调形式,以及支持以上属性的数组和动态添加形式。

字符串

class TestMiddleware {
  // ...
  match = '/test';
}

正则

class TestMiddleware {
  // ...
  match = /^\/test/;
}

方法

class TestMiddleware {
  // ...
  match(ctx) {
    // ...
  }
}

混合

class TestMiddleware {
  // ...
  match = ['/123', /^\/test/, (ctx) => {})]
}

动态(一般用于组件中定义中间件,需要用户配置合并的情况)

class TestMiddleware {

  @Config('test.match')
  testMatchConfig: [];

  match = [];

  @Init()
  async init() {
     this.match.push('/123');
     this.match.push(...this.tesetMatchConfig);
  }
}

@czy88840616 czy88840616 added the pr: new feature This PR adds a new API or behavior. label Mar 19, 2023
@codecov-commenter
Copy link

codecov-commenter commented Mar 19, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.09 🎉

Comparison is base (efaa3de) 82.01% compared to head (6d500de) 82.11%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2805      +/-   ##
==========================================
+ Coverage   82.01%   82.11%   +0.09%     
==========================================
  Files         421      421              
  Lines       15129    15143      +14     
  Branches     3590     3592       +2     
==========================================
+ Hits        12408    12434      +26     
+ Misses       2471     2460      -11     
+ Partials      250      249       -1     
Impacted Files Coverage Δ
packages/core/src/interface.ts 100.00% <ø> (ø)
packages/core/src/service/middlewareService.ts 90.62% <ø> (+14.86%) ⬆️
packages/core/src/util/index.ts 83.78% <100.00%> (+1.25%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@czy88840616 czy88840616 merged commit fb996b5 into main Mar 25, 2023
@czy88840616 czy88840616 deleted the add_match_arr_support branch March 25, 2023 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new feature This PR adds a new API or behavior.
Development

Successfully merging this pull request may close these issues.

2 participants