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

how to get the value in req when type is in:header #2036

Closed
zcyc opened this issue Jul 28, 2022 · 2 comments
Closed

how to get the value in req when type is in:header #2036

zcyc opened this issue Jul 28, 2022 · 2 comments
Labels
cannot reproduce We cannot reproduce it, it might resolved in new version or you should give more details. planned This issue/proposal is planned into our next steps.

Comments

@zcyc
Copy link
Contributor

zcyc commented Jul 28, 2022

1. What version of Go and system type/arch are you using?

1.18.4

2. What version of GoFrame are you using?

2.1.2

3. Can this issue be re-produced with the latest release?

yes

4. What did you do?

i want to defind a header like Authorization in my PasswordChangeReq and valid it.
this is my PasswordChangeReq

type PasswordChangeReq struct {
	g.Meta        `path:"/change" tags:"password" method:"post" summary:"change"`
	Authorization string `v:"required#Authorization is null" in:"header"`
	Password      string `json:"password" v:"required|length:8,32#password is null"`
}

can i get Authorization in my controller use req.Authorization

func (c *cPassword) PasswordChange(ctx context.Context, req *v1.PasswordChangeReq) (res *v1.PasswordChangeRes, err error) {
	// how can i get the header in PasswordChangeReq
        // if can't get value, it is only show in openAPI, and i can't set valid for it
	g.Log().Info(ctx, req.Authorization)
	return
}

5. What did you expect to see?

{
    "code": 51,
    "message": "Authorization is null",
    "data": null
}

6. What did you see instead?

{
    "code": 0,
    "message": "",
    "data": null
}
@zcyc zcyc changed the title in: "header" 如何通过 struct 取值 how can i get the value in req when type is header Jul 28, 2022
@zcyc zcyc changed the title how can i get the value in req when type is header how can i get the value in req when type is in:header Jul 28, 2022
@zcyc zcyc changed the title how can i get the value in req when type is in:header how to get the value in req when type is in:header Aug 3, 2022
@gqcn gqcn added planned This issue/proposal is planned into our next steps. and removed inactive labels Jan 18, 2023
@oldme-git
Copy link
Member

In my test, It can print header's value successfully. Gf Version: 2.6.2

@oldme-git oldme-git added the cannot reproduce We cannot reproduce it, it might resolved in new version or you should give more details. label Feb 4, 2024
@zcyc
Copy link
Contributor Author

zcyc commented Feb 10, 2024

In my test, It can print header's value successfully. Gf Version: 2.6.2

ok,i see the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot reproduce We cannot reproduce it, it might resolved in new version or you should give more details. planned This issue/proposal is planned into our next steps.
Projects
None yet
Development

No branches or pull requests

3 participants