{"id":13412890,"url":"https://github.com/ggicci/httpin","last_synced_at":"2026-01-16T18:39:38.322Z","repository":{"id":39603798,"uuid":"357397546","full_name":"ggicci/httpin","owner":"ggicci","description":"🍡 HTTP Input for Go - HTTP Request from/to Go Struct (Bi-directional Data Binding between Go Struct and http.Request)","archived":false,"fork":false,"pushed_at":"2025-11-20T22:03:46.000Z","size":1640,"stargazers_count":382,"open_issues_count":13,"forks_count":27,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-11T20:46:35.122Z","etag":null,"topics":["data-binding","go","go-api","go-http","go-http-middleware","go-http-requests","go-rest-api","http-request-params-reader"],"latest_commit_sha":null,"homepage":"https://ggicci.github.io/httpin/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ggicci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"ggicci","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2021-04-13T02:15:36.000Z","updated_at":"2026-01-07T15:23:20.000Z","dependencies_parsed_at":"2023-11-13T06:34:52.896Z","dependency_job_id":"e8f4a7e4-046b-4e22-aead-71a814b89377","html_url":"https://github.com/ggicci/httpin","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/ggicci/httpin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fhttpin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fhttpin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fhttpin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fhttpin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ggicci","download_url":"https://codeload.github.com/ggicci/httpin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fhttpin/sbom","scorecard":{"id":29736,"data":{"date":"2025-08-04","repo":{"name":"github.com/ggicci/httpin","commit":"62858140ae3d12b723a7ad8fa7bbf17c50a46d62"},"scorecard":{"version":"v5.2.1-28-gc1d103a9","commit":"c1d103a9bb9f635ec7260bf9aa0699466fa4be0e"},"score":4.5,"checks":[{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":5,"reason":"4 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#maintained"}},{"name":"Code-Review","score":3,"reason":"Found 4/11 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/ggicci/httpin/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/ggicci/httpin/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/ggicci/httpin/go.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 27 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2025-3770 / GHSA-vrw8-fxc6-2r93"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-14T18:46:21.089Z","repository_id":39603798,"created_at":"2025-08-14T18:46:21.090Z","updated_at":"2025-08-14T18:46:21.090Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28472620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T20:50:13.584Z","status":"ssl_error","status_checked_at":"2026-01-15T20:49:17.379Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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"}},"keywords":["data-binding","go","go-api","go-http","go-http-middleware","go-http-requests","go-rest-api","http-request-params-reader"],"created_at":"2024-07-30T20:01:30.677Z","updated_at":"2026-01-16T18:39:38.290Z","avatar_url":"https://github.com/ggicci.png","language":"Go","funding_links":["https://github.com/sponsors/ggicci"],"categories":["Forms","表单"],"sub_categories":["Search and Analytic Databases","检索及分析资料库","Advanced Console UIs"],"readme":"\u003ca href=\"https://ggicci.github.io/httpin/\"\u003e\n  \u003cimg src=\"https://ggicci.github.io//httpin/img/emoji-dango.png\" alt=\"httpin logo\" title=\"httpin Documentation\" align=\"right\" height=\"60\" /\u003e\n\u003c/a\u003e\n\n# httpin - HTTP Input for Go\n\n\u003cdiv align=\"center\"\u003e\u003ch3\u003eHTTP Request from/to Go Struct\u003c/h3\u003e\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Go](https://github.com/ggicci/httpin/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/ggicci/httpin/actions/workflows/go.yml) [![documentation](https://github.com/ggicci/httpin/actions/workflows/documentation.yml/badge.svg?branch=documentation)](https://github.com/ggicci/httpin/actions/workflows/documentation.yml) [![codecov](https://codecov.io/gh/ggicci/httpin/branch/main/graph/badge.svg?token=RT61L9ngHj)](https://codecov.io/gh/ggicci/httpin) [![Go Report Card](https://goreportcard.com/badge/github.com/ggicci/httpin)](https://goreportcard.com/report/github.com/ggicci/httpin) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go) [![Go Reference](https://pkg.go.dev/badge/github.com/ggicci/httpin.svg)](https://pkg.go.dev/github.com/ggicci/httpin)\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003ca href=\"https://ggicci.github.io/httpin/\"\u003e\n        \u003cimg src=\"https://docusaurus.io/img/docusaurus.svg\" height=\"48px\" /\u003e\n      \u003c/a\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003ca href=\"https://ggicci.github.io/httpin/\"\u003eDocumentation\u003c/a\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c/div\u003e\n\n## Core Features\n\n**httpin** helps you easily decode data from an HTTP request, including:\n\n- **Query parameters**, e.g. `?name=john\u0026is_member=true`\n- **Headers**, e.g. `Authorization: xxx`\n- **Form data**, e.g. `username=john\u0026password=******`\n- **JSON/XML Body**, e.g. `POST {\"name\":\"john\"}`\n- **Path variables**, e.g. `/users/{username}`\n- **File uploads**\n\nYou **only** need to define a struct to receive/bind data from an HTTP request, **without** writing any parsing stuff code by yourself.\n\nSince v0.15.0, httpin also supports creating an HTTP request (`http.Request`) from a Go struct instance.\n\n**httpin** is:\n\n- **well documented**: at https://ggicci.github.io/httpin/\n- **open integrated**: with [net/http](https://ggicci.github.io/httpin/integrations/http), [go-chi/chi](https://ggicci.github.io/httpin/integrations/gochi), [gorilla/mux](https://ggicci.github.io/httpin/integrations/gorilla), [gin-gonic/gin](https://ggicci.github.io/httpin/integrations/gin), etc.\n- **extensible** (advanced feature): by adding your custom directives. Read [httpin - custom directives](https://ggicci.github.io/httpin/directives/custom) for more details.\n\n## Add Httpin Directives by Tagging the Struct Fields with `in`\n\n```go\ntype ListUsersInput struct {\n\tToken    string  `in:\"query=access_token;header=x-access-token\"`\n\tPage     int     `in:\"query=page;default=1\"`\n\tPerPage  int     `in:\"query=per_page;default=20\"`\n\tIsMember bool    `in:\"query=is_member\"`\n    Search   *string `in:\"query=search;omitempty\"`\n}\n```\n\n## How to decode an HTTP request to Go struct?\n\n```go\nfunc ListUsers(rw http.ResponseWriter, r *http.Request) {\n\tinput := r.Context().Value(httpin.Input).(*ListUsersInput)\n\n\tif input.IsMember {\n\t\t// Do sth.\n\t}\n\t// Do sth.\n}\n```\n\n## How to encode a Go struct to HTTP request?\n\n```go\nfunc SDKListUsers() {\n\tpayload := \u0026ListUsersInput{\n\t\tToken:    os.Getenv(\"MY_APP_ACCESS_TOKEN\"),\n\t\tPage:     2,\n\t\tIsMember: true,\n\t}\n\n\t// Easy to remember, http.NewRequest -\u003e httpin.NewRequest\n\treq, err := httpin.NewRequest(\"GET\", \"/users\", payload)\n\t// ...\n}\n```\n\n## Why this package?\n\n#### Compared with using `net/http` package\n\n```go\nfunc ListUsers(rw http.ResponseWriter, r *http.Request) {\n\tpage, err := strconv.ParseInt(r.FormValue(\"page\"), 10, 64)\n\tif err != nil {\n\t\t// Invalid parameter: page.\n\t\treturn\n\t}\n\tperPage, err := strconv.ParseInt(r.FormValue(\"per_page\"), 10, 64)\n\tif err != nil {\n\t\t// Invalid parameter: per_page.\n\t\treturn\n\t}\n\tisMember, err := strconv.ParseBool(r.FormValue(\"is_member\"))\n\tif err != nil {\n\t\t// Invalid parameter: is_member.\n\t\treturn\n\t}\n\n\t// Do sth.\n}\n```\n\n| Benefits                | Before (use net/http package)              | After (use ggicci/httpin package)                                                              |\n| ----------------------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------- |\n| ⌛️ Developer Time      | 😫 Expensive (too much parsing stuff code) | 🚀 **Faster** (define the struct for receiving input data and leave the parsing job to httpin) |\n| ♻️ Code Repetition Rate | 😞 High                                    | 😍 **Lower**                                                                                   |\n| 📖 Code Readability     | 😟 Poor                                    | 🤩 **Highly readable**                                                                         |\n| 🔨 Maintainability      | 😡 Poor                                    | 🥰 **Highly maintainable**                                                                     |\n\n## Alternatives and Similars\n\n- [gorilla/schema](https://github.com/gorilla/schema): converts structs to and from form values\n- [google/go-querystring](https://github.com/google/go-querystring): encoding structs into URL query parameters\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fggicci%2Fhttpin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fggicci%2Fhttpin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fggicci%2Fhttpin/lists"}