{"id":12519750,"name":"rivaas.dev/binding","ecosystem":"go","description":"Package binding provides request data binding for HTTP handlers.\n\nThe binding package maps values from various sources (query parameters,\nform data, JSON bodies, headers, cookies, path parameters) into Go structs\nusing struct tags. It supports nested structs, slices, maps, pointers,\ncustom types, default values, and type conversion.\n\nNote: For validation (required fields, enum constraints, etc.), use the\nrivaas.dev/validation package separately after binding.\n\nThe binding package follows the functional options pattern:\n\nThe package provides both generic and non-generic APIs:\n\nEach binding source has dedicated functions:\n\nBind from multiple sources using From* options:\n\nBind multipart forms with file uploads directly to structs using the form tag.\nThis enables handling file uploads and form values in a single struct:\n\nFile fields use the *File or []*File types and support the same struct tag syntax\nas other binding sources (defaults, aliases, etc.). The File type provides\nmethods for reading, streaming, and saving uploaded files with built-in\nsecurity (filename sanitization, path cleaning).\n\n## JSON in Form Fields\n\nMultipart binding automatically detects and parses JSON strings in form fields:\n\nIf the form field value starts with { or [ and ends with } or ], the binding\nautomatically attempts JSON unmarshaling. If JSON parsing fails, it falls back\nto dot-notation parsing (settings.orientation=landscape).\n\n## File Security\n\nThe File type includes built-in security features:\n\nBest practices for file handling:\n\nUse functional options to customize binding behavior:\n\nFor shared configuration, create a Binder instance:\n\nThe package uses struct tags to map values:\n\nThe following formats are available as sub-packages:\n\nExample with YAML:\n\nExample with TOML:\n\nExample with MessagePack:\n\nExample with Protocol Buffers:\n\ndefault:\"value\": Default value when field is not present in the input.\nWorks for all binding sources: query, path, header, cookie, form, and JSON body.\nSupported for all primitive types (string, int*, uint*, float*, bool),\ntime.Time, time.Duration, net.IP, url.URL, and their pointer variants.\nFor slices, use comma-separated values: default:\"a,b,c\"\nWhitespace around comma-separated elements is trimmed.\nNot supported for map fields.\n\nFor JSON body binding, defaults are applied after decoding. A field\nexplicitly sent as its zero value (e.g. {\"active\": false}) is NOT\noverwritten by the default — only fields absent from the JSON payload\nreceive their default value. This also works for nested structs when the\nparent key is present in the JSON.\n\nFor validation constraints (required, enum, etc.), use the rivaas.dev/validation\npackage with the `validate` struct tag.\n\nBuilt-in support for common types:\n\nRegister custom converters:\n\nThe package provides factory functions for common converter patterns:\n\n## Custom Time Layouts\n\nUse TimeConverter to parse times in non-standard formats:\n\n## Duration Aliases\n\nUse DurationConverter to provide user-friendly duration names:\n\n## Enum Validation\n\nUse EnumConverter to validate against allowed values:\n\n## Custom Boolean Values\n\nUse BoolConverter to accept non-standard boolean representations:\n\n## Combining Multiple Converters\n\nYou can use multiple converter factories together:\n\n## Third-Party Type Examples\n\nFor types from third-party packages, use WithConverter:\n\nOr with a custom wrapper for error handling:\n\nErrors provide detailed context:\n\nCollect all errors instead of failing on first:\n\nAdd hooks for monitoring:\n\nBuilt-in limits prevent resource exhaustion:\n\nConfigure limits:\n\nThe package provides extensive configuration through functional options:\n\n## Security Limits\n\n## Unknown Fields\n\n## Slice Parsing\n\n## Time Formats\n\n## Type Converters\n\n## Error Handling\n\n## Observability\n\n## Key Normalization\n\n## Tag Aliases\n\nProvide multiple lookup names for a field:\n\n## Nested Structs\n\nUse dot notation for nested fields:\n\n## Bracket Notation\n\nArrays can use bracket notation:\n\nFor large payloads, use Reader variants to avoid loading entire body into memory:\n\nReader variants are available for all body-based sources (JSON, XML, and sub-packages).\n\n## Caching\n\nStruct reflection information is cached automatically:\n\n## Memory Allocation\n\n## Multi-Source Binding Precedence\n\nWhen using Bind with multiple sources, later sources override earlier ones:\n\nThis allows for flexible request handling where body data takes precedence\nover URL parameters.\n\nFor simple map-based sources, use the convenience helpers:\n\nFor more complex sources, implement the ValueGetter interface:\n\nAlternatively, use GetterFunc for a function-based adapter:\n\n## With net/http\n\n## With rivaas.dev/router\n\n## With rivaas.dev/app\n\nThe package provides detailed error types for different failure scenarios:\n\nAll error types implement standard error interfaces and integrate with\nrivaas.dev/errors for HTTP status code mapping.\n\nThis package works independently without the full Rivaas framework. Use it\nwith any Go HTTP handler (net/http, Gin, Echo, etc.).","homepage":"https://github.com/rivaas-dev/rivaas","licenses":"Apache-2.0","normalized_licenses":["Apache-2.0"],"repository_url":null,"keywords_array":[],"namespace":"rivaas.dev","versions_count":16,"first_release_published_at":"2025-11-24T11:36:57.000Z","latest_release_published_at":"2026-03-24T15:31:49.000Z","latest_release_number":"v0.9.0","last_synced_at":"2026-05-30T03:45:57.170Z","created_at":"2025-11-25T10:43:28.975Z","updated_at":"2026-05-30T03:45:57.170Z","registry_url":"https://pkg.go.dev/rivaas.dev/binding","install_command":"go get rivaas.dev/binding","documentation_url":"https://pkg.go.dev/rivaas.dev/binding#section-documentation","metadata":{},"repo_metadata":{"id":317391200,"uuid":"1065746388","full_name":"rivaas-dev/rivaas","owner":"rivaas-dev","description":"High-performance API framework for Go","archived":false,"fork":false,"pushed_at":"2026-03-24T10:20:04.000Z","size":25517,"stargazers_count":30,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-24T13:08:16.296Z","etag":null,"topics":["cloud-native","framework","golang","logging","metrics","observability","openapi3","openapi31","opentelemetry","router","tracing"],"latest_commit_sha":null,"homepage":"https://rivaas.dev","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rivaas-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-28T10:49:29.000Z","updated_at":"2026-03-24T10:20:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"22e5fdae-94a0-4514-ab93-bada5662c9ea","html_url":"https://github.com/rivaas-dev/rivaas","commit_stats":null,"previous_names":["rivaas-dev/rivaas"],"tags_count":231,"template":false,"template_full_name":null,"purl":"pkg:github/rivaas-dev/rivaas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivaas-dev%2Frivaas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivaas-dev%2Frivaas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivaas-dev%2Frivaas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivaas-dev%2Frivaas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rivaas-dev","download_url":"https://codeload.github.com/rivaas-dev/rivaas/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivaas-dev%2Frivaas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30926963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-25T07:55:14.202Z","status":"ssl_error","status_checked_at":"2026-03-25T07:55:10.924Z","response_time":80,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"},"tags":[]},"repo_metadata_updated_at":"2026-04-26T00:17:22.646Z","dependent_packages_count":0,"downloads":null,"downloads_period":null,"dependent_repos_count":0,"rankings":{"downloads":null,"dependent_repos_count":5.418443364761353,"dependent_packages_count":5.077359904960262,"stargazers_count":null,"forks_count":null,"docker_downloads_count":null,"average":5.247901634860807},"purl":"pkg:golang/rivaas.dev/binding","advisories":[],"docker_usage_url":"https://docker.ecosyste.ms/usage/go/rivaas.dev/binding","docker_dependents_count":null,"docker_downloads_count":null,"usage_url":"https://repos.ecosyste.ms/usage/go/rivaas.dev/binding","dependent_repositories_url":"https://repos.ecosyste.ms/api/v1/usage/go/rivaas.dev/binding/dependencies","status":null,"funding_links":[],"critical":null,"issue_metadata":{"last_synced_at":null,"issues_count":null,"pull_requests_count":null,"avg_time_to_close_issue":null,"avg_time_to_close_pull_request":null,"issues_closed_count":null,"pull_requests_closed_count":null,"pull_request_authors_count":null,"issue_authors_count":null,"avg_comments_per_issue":null,"avg_comments_per_pull_request":null,"merged_pull_requests_count":null,"bot_issues_count":null,"bot_pull_requests_count":null,"past_year_issues_count":null,"past_year_pull_requests_count":null,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":null,"past_year_issues_closed_count":null,"past_year_pull_requests_closed_count":null,"past_year_pull_request_authors_count":null,"past_year_issue_authors_count":null,"past_year_avg_comments_per_issue":null,"past_year_avg_comments_per_pull_request":null,"past_year_bot_issues_count":null,"past_year_bot_pull_requests_count":null,"past_year_merged_pull_requests_count":null,"issues_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivaas-dev%2Frivaas/issues","maintainers":[],"active_maintainers":[]},"versions_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/rivaas.dev%2Fbinding/versions","version_numbers_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/rivaas.dev%2Fbinding/version_numbers","latest_version_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/rivaas.dev%2Fbinding/latest_version","dependent_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/rivaas.dev%2Fbinding/dependent_packages","related_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/rivaas.dev%2Fbinding/related_packages","codemeta_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/rivaas.dev%2Fbinding/codemeta","maintainers":[]}