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

fix: use generics to parse request params #1462

Closed
wants to merge 17 commits into from

Conversation

kangmingtay
Copy link
Member

@kangmingtay kangmingtay commented Mar 1, 2024

What kind of change does this PR introduce?

  • Introduce a new method retrieveRequestParams which makes use of generics to parse a request
  • This will help to simplify parsing a request from:
params := RequestParams{}
body, err := getBodyBytes(r)
if err != nil {
  return nil, badRequestError("Could not read body").WithInternalError(err)
}

if err := json.Unmarshal(body, &params); err != nil {
  return nil, badRequestError("Could not decode request params: %v", err)
}

to

params, err := retrieveRequestParams(req, &Request{})

TODO

  • Add type constraint instead of using any

@kangmingtay kangmingtay requested a review from a team as a code owner March 1, 2024 11:51
Base automatically changed from km/feat-anonymous-logins to master March 3, 2024 03:51
@kangmingtay
Copy link
Member Author

refer to #1464 instead

@kangmingtay kangmingtay closed this Mar 3, 2024
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

Successfully merging this pull request may close these issues.

1 participant