mirror of
https://github.com/SigNoz/signoz.git
synced 2026-06-20 15:20:31 +01:00
Some checks failed
build-staging / js-build (push) Has been cancelled
build-staging / prepare (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
* feat: extend error responses with new error struct
* fix: enriched error for dashboard api
* fix: merge issues
* fix: reverted dashboards changes and add for cloud integrations
* fix: delete file
* fix: add back file
* fix: added a helper
* fix: removed invlaid referencess
* fix: generate openapi
* fix: keeping additional along with suggestion
* Revert "fix: keeping additional along with suggestion"
This reverts commit be30e2ffd2.
* fix: added suggestions per additonal error
* fix: generate openapi
* fix: remove valid references
* fix: removeg valid references for select and group by and only did you mean is kept
* fix: unit test
* fix: use binding for deconding for both ee and community
* fix: trim down suggestions methods
* fix: added renamed methods and moved stuff around
* fix: typo
* fix: removed json decoder
* fix: added empty check
* fix: retain addtional
* fix: reverted re-structing of file
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package binding
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/SigNoz/signoz/pkg/errors"
|
|
)
|
|
|
|
var (
|
|
ErrCodeInvalidRequestBody = errors.MustNewCode("invalid_request_body")
|
|
ErrCodeInvalidRequestField = errors.MustNewCode("invalid_request_field")
|
|
ErrCodeInvalidRequestQuery = errors.MustNewCode("invalid_request_query")
|
|
)
|
|
|
|
var (
|
|
JSON BindingBody = &jsonBinding{}
|
|
Query BindingQuery = &queryBinding{}
|
|
)
|
|
|
|
type bindBodyOptions struct {
|
|
DisallowUnknownFields bool
|
|
UseNumber bool
|
|
UnknownFieldContext string
|
|
}
|
|
|
|
type BindBodyOption func(*bindBodyOptions)
|
|
|
|
func WithDisallowUnknownFields(disallowUnknownFields bool) BindBodyOption {
|
|
return func(options *bindBodyOptions) {
|
|
options.DisallowUnknownFields = disallowUnknownFields
|
|
}
|
|
}
|
|
|
|
func WithUnknownFieldContext(context string) BindBodyOption {
|
|
return func(options *bindBodyOptions) {
|
|
options.UnknownFieldContext = context
|
|
}
|
|
}
|
|
|
|
func WithUseNumber(useNumber bool) BindBodyOption {
|
|
return func(options *bindBodyOptions) {
|
|
options.UseNumber = useNumber
|
|
}
|
|
}
|
|
|
|
type BindingBody interface {
|
|
BindBody(body io.Reader, obj any, opts ...BindBodyOption) error
|
|
}
|
|
|
|
type BindingQuery interface {
|
|
BindQuery(query map[string][]string, obj any) error
|
|
}
|