Skip to content

Releases: ggicci/httpin

v0.20.2

02 Oct 07:18
5ec1e69

Choose a tag to compare

#126 Expose core.ErrFailedToParseRequestForm for handling decoding error.

v0.20.1

28 Jul 01:20

Choose a tag to compare

Nothing but dependencies upgrade to resolve security alerts.

v0.20.0

10 May 03:08
a1cbbf5

Choose a tag to compare

New Features

httpin now supports encoding and decoding path variables when using the native net/http package for routing.

This feature was brough in #113 by @chriss-de, thanks :)

import httpin_integration "github.com/ggicci/httpin/integration"

func init() {
	httpin_integration.UseHttpPathVariable("path")
}

Breaking Changes

The API UseEchoPathRouter(e) was removed due to unnecessary abstraction, please migrate to use UseEchoPathRouter("path", e) instead.

v0.19.0

20 May 23:00
eed0621

Choose a tag to compare

New Feature

Introduced a new directive omitempty, which works on encoding a Go struct to an http.Request. Just think of how omitempty works in encoding/json package. Here in httpin, omitempty will omit adding keys to Query, Form, Header when the corresponding value is empty. See reflect.Value.IsZero for more details about how we judge an empty value.

#107

Thanks to @alecsammon who made this feature availalbe for all httpin users.

v0.18.1

30 Apr 03:51
6a628af

Choose a tag to compare

Remove indirect dependency to echo by moving the testing code under _test package.

v0.18.0

20 Apr 23:12
31c7322

Choose a tag to compare

Fixes #101

Breaking Change and Migration Guide

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.

How to migrate to v0.18.0?

Since we haven't changed the signature of this function, we can migrate by replacing httpin.Decode with httpin.DecodeTo in your codebase.

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

v0.17.0

15 Mar 05:51
c8657ee

Choose a tag to compare

#99 Added echo integration, register a "path" directive that can work with echo router.

import httpin_integration "github.com/ggicci/httpin/integration"

func init() {
    e := echo.New()
    httpin_integration.UseEchoRouter("path", e)

    // or
    httpin_integration.UseEchoPathRouter(e)
}

Thanks

@sorenmat

v0.16.0

28 Jan 23:47

Choose a tag to compare

API Changes

Added optional parameter opts ...core.Option to the following APIs:

  • httpin.Decode(req *http.Request, input any) error -> httpin.Decode(req *http.Request, input any, opts ...core.Option) error
  • httpin.NewRequest(method, url string, input any) (*http.Request, error) -> httpin.NewRequest(method, url string, input any, opts ...core.Option) (*http.Request, error)
  • httpin.NewRequestWithContext(ctx context.Context, method, url string, input any) (*http.Request, error) -> httpin.NewRequestWithContext(ctx context.Context, method, url string, input any, opts ...core.Option) (*http.Request, error)

Added a new variable httpin.Option where is a collection of the options.

v0.15.3

14 Jan 18:36
5dca4c8

Choose a tag to compare

Fixed #88 - make httpin able to stream uploading large files.

Thanks @excavador

v0.15.2

31 Dec 07:08

Choose a tag to compare

Register the path directive by default, but it only supports encoding function. For a complete path directive, users still need to use the integration subpackage:

import httpin_integration "github.com/ggicci/httpin/integration"

func init() {
	httpin_integration.UseGochiURLParam("gochi", chi.URLParam)
}