You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Include encoding functionality to this package. From now on, httpin doesn't only support decoding an HTTP request to a Go struct, it supports encoding a Go struct to an HTTP request as well. Simply call httpin.NewRequest method. Because all the builtin directives now support encoding functions.
Introduced a new directive named nonzero. Which is used to cover/correct miss-use of the required directive, use nonzero instead of required to ensure that the field not be a zero/empty value.
For custom struct types, you don't need to register it to httpin any more, as long as you implement the Stringable interface.
Breaking Changes
Less APIs are exposed under package httpin. I hope the list will be limited to the following, which I would like to keep in the first stable release (v1.0.0):
httpin.New: creates a core.Core instance;
httpin.NewInput: creates a HTTP middleware;
httpin.Input: the context key to retrieve the decoded struct instance that was injected to http.Request.Context by httpin;
httpin.Decode: decode an HTTP request to a struct instance;
httpin.NewRequest: encode a struct instance to an HTTP request;
httpin.NewRequestWithContext: call httpin.NewRequest with a context.Context;
httpin.File: the type for manipulating file uploading in httpin;
httpin.UploadFile: upload file by filename;
httpin.UploadStream: upload file by stream.
APIs to integrate with third-party packages are moved to the integration subpackage:
httpin.UseGochiURLParam: registers a path directive for the gochi routing package, use httpin_integration.UseGochiURLParam instead;
httpin.UseGorillaMux: registers a path directive for the gorilla/mux routing package, use httpin_integration.UseGorillaMux instead;
All the other APIs used to extend http functions are moved to core subpackage and many of them have been changed because the newly introduced encoding ability:
httpin.RegisterValueTypeDecoder[T]: use httpin_core.RegisterCoder instead;
httpin.RegisterNamedDecoder[T]: use httpin_core.RegisterNamedCoder[T] instead;
httpin.RegisterFileTypeDecoder[T]: use httpin_core.RegisterFileCoder[T] instead;
httpin.RegisterBodyDecoder: use httpin_core.RegisterBodyFormat instead;
httpin.ReplaceDefaultErrorHandler: use httpin_core.RegisterErrorHandler instead;
DEPRECATED httpin.ReplaceValueTypeDecoder[T]: use httpin_core.RegisterCoder instead;
DEPRECATED httpin.ReplaceNamedDecoder[T]: use httpin_core.RegisterNamedCoder[T] instead;
DEPRECATED httpin.ReplaceFileTypeDecoder[T]: use httpin_core.RegisterFileCoder[T] instead;
DEPRECATED httpin.ReplaceBodyDecoder: use httpin_core.RegisterBodyFormat instead;