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/decode api update #105

Merged
merged 3 commits into from
Apr 20, 2024
Merged

Feat/decode api update #105

merged 3 commits into from
Apr 20, 2024

Conversation

ggicci
Copy link
Owner

@ggicci ggicci commented Apr 20, 2024

Breaking Change

func DecodeTo(req *http.Request, input any, opts ...core.Option) error API has been renamed to DecodeTo, it will populate the given input value instead of creating a new instance internally, updates #101

New API

Added new func Decode[T any](req *http.Request, opts ...core.Option) (*T, error) API, example usage:

type AddUserInput struct {
	Username string `in:"form=username"`
}
if input, err := httpin.Decode[AddUserInput](req); err != nil { ... }
// input.Username

The original Decode() api is renamed to DecodeTo(), and the newly added
Decode() api is a generic version.
Copy link

codecov bot commented Apr 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.78%. Comparing base (c8657ee) to head (e72964c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #105      +/-   ##
==========================================
+ Coverage   90.67%   90.78%   +0.10%     
==========================================
  Files          34       34              
  Lines        1512     1530      +18     
==========================================
+ Hits         1371     1389      +18     
  Misses         97       97              
  Partials       44       44              
Flag Coverage Δ
unittests 90.78% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ggicci ggicci merged commit 31c7322 into main Apr 20, 2024
3 checks passed
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