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

request header 请求首字符大写问题 #63

Open
hawkj opened this issue Sep 15, 2021 · 1 comment
Open

request header 请求首字符大写问题 #63

hawkj opened this issue Sep 15, 2021 · 1 comment

Comments

@hawkj
Copy link

hawkj commented Sep 15, 2021

在demo中,对于传入的header注解:@Header(key="token|接口访问凭证", rule="required")。当进行header规则验证的时候,会将该key的首字符大写。
ValidationApi.php:128
$real_headers[implode('-', array_map('ucfirst', explode('-', $key)))] = $val;
因此注解中@Header(key="token|接口访问凭证", rule="required") 如果首字母是小写的,会报错:
[ERROR] 接口访问凭证 字段是必须的[69] in /var/workspace/hyperf-skeleton/vendor/daodao97/apidog/src/Middleware/ApiValidationMiddleware.php.
原因是token首字母是小写,所以找不到。
综上:
在注解header中,key的首字母必须大写。demo中是小写的。

@daodao97
Copy link
Owner

标准的header参数格式为 Aaa-Bbb, 但是hyperf request 底层转换时,会把所有的header参数全部小写化,aaa-bbb 这种

所以验证时又不得不再次转换,才能找到对应的key, 但是要求就是 必须是一个规范的 header 参数名

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants