{"id":13367295,"url":"https://github.com/mozillazg/Go-httpheader","last_synced_at":"2025-03-12T18:32:21.493Z","repository":{"id":22166385,"uuid":"95293551","full_name":"mozillazg/go-httpheader","owner":"mozillazg","description":"A Go library for encoding structs into Header fields.","archived":false,"fork":false,"pushed_at":"2023-07-15T18:34:06.000Z","size":57,"stargazers_count":47,"open_issues_count":0,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-03T15:40:43.023Z","etag":null,"topics":["go","go-library","golang","header","struct","structs"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/mozillazg/go-httpheader","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/mozillazg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2017-06-24T11:28:06.000Z","updated_at":"2024-07-27T17:42:59.000Z","dependencies_parsed_at":"2024-06-18T13:59:02.714Z","dependency_job_id":"d55811b5-a9f4-4ad1-9aab-5a50ba1d06ef","html_url":"https://github.com/mozillazg/go-httpheader","commit_stats":{"total_commits":43,"total_committers":4,"mean_commits":10.75,"dds":"0.16279069767441856","last_synced_commit":"00e0d97353778d8dea8a7fbf202e274edb9d40b6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Fgo-httpheader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Fgo-httpheader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Fgo-httpheader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Fgo-httpheader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mozillazg","download_url":"https://codeload.github.com/mozillazg/go-httpheader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221309966,"owners_count":16795836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["go","go-library","golang","header","struct","structs"],"created_at":"2024-07-30T00:01:43.883Z","updated_at":"2024-10-24T11:31:10.527Z","avatar_url":"https://github.com/mozillazg.png","language":"Go","readme":"# go-httpheader\n\ngo-httpheader is a Go library for encoding structs into Header fields.\n\n[![Build Status](https://github.com/mozillazg/go-httpheader/workflows/CI/badge.svg?branch=master)](https://github.com/mozillazg/go-httpheader/actions)\n[![Coverage Status](https://coveralls.io/repos/github/mozillazg/go-httpheader/badge.svg?branch=master)](https://coveralls.io/github/mozillazg/go-httpheader?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mozillazg/go-httpheader)](https://goreportcard.com/report/github.com/mozillazg/go-httpheader)\n[![GoDoc](https://godoc.org/github.com/mozillazg/go-httpheader?status.svg)](https://godoc.org/github.com/mozillazg/go-httpheader)\n\n## install\n\n```\ngo get github.com/mozillazg/go-httpheader\n```\n\n\n## usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/mozillazg/go-httpheader\"\n)\n\ntype Options struct {\n\thide         string\n\tContentType  string `header:\"Content-Type\"`\n\tLength       int\n\tXArray       []string `header:\"X-Array\"`\n\tTestHide     string   `header:\"-\"`\n\tIgnoreEmpty  string   `header:\"X-Empty,omitempty\"`\n\tIgnoreEmptyN string   `header:\"X-Empty-N,omitempty\"`\n\tCustomHeader http.Header\n}\n\nfunc main() {\n\topt := Options{\n\t\thide:         \"hide\",\n\t\tContentType:  \"application/json\",\n\t\tLength:       2,\n\t\tXArray:       []string{\"test1\", \"test2\"},\n\t\tTestHide:     \"hide\",\n\t\tIgnoreEmptyN: \"n\",\n\t\tCustomHeader: http.Header{\n\t\t\t\"X-Test-1\": []string{\"233\"},\n\t\t\t\"X-Test-2\": []string{\"666\"},\n\t\t},\n\t}\n\th, _ := httpheader.Header(opt)\n\tfmt.Printf(\"%#v\", h)\n\t// h:\n\t// http.Header{\n\t//\t\"X-Test-1\":     []string{\"233\"},\n\t//\t\"X-Test-2\":     []string{\"666\"},\n\t//\t\"Content-Type\": []string{\"application/json\"},\n\t//\t\"Length\":       []string{\"2\"},\n\t//\t\"X-Array\":      []string{\"test1\", \"test2\"},\n\t//\t\"X-Empty-N\":    []string{\"n\"},\n\t// }\n\t\n\t// decode\n\tvar decode Options\n\thttpheader.Decode(h, \u0026decode)\n}\n```\n","funding_links":[],"categories":["实用工具","實用工具"],"sub_categories":["高级控制台界面","高級控制台界面"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozillazg%2FGo-httpheader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmozillazg%2FGo-httpheader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozillazg%2FGo-httpheader/lists"}