{"id":22385245,"url":"https://github.com/acoshift/cors","last_synced_at":"2025-06-28T11:32:38.876Z","repository":{"id":73779600,"uuid":"79553507","full_name":"acoshift/cors","owner":"acoshift","description":"CORS middleware for Golang net/http","archived":false,"fork":false,"pushed_at":"2017-08-06T16:27:56.000Z","size":5,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T20:26:18.070Z","etag":null,"topics":["cors","golang","http","middleware"],"latest_commit_sha":null,"homepage":"","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/acoshift.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}},"created_at":"2017-01-20T11:26:45.000Z","updated_at":"2017-08-17T14:57:42.000Z","dependencies_parsed_at":"2024-06-20T17:18:19.272Z","dependency_job_id":null,"html_url":"https://github.com/acoshift/cors","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/acoshift/cors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fcors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fcors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fcors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fcors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acoshift","download_url":"https://codeload.github.com/acoshift/cors/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fcors/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262421822,"owners_count":23308520,"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":["cors","golang","http","middleware"],"created_at":"2024-12-05T01:22:25.218Z","updated_at":"2025-06-28T11:32:38.858Z","avatar_url":"https://github.com/acoshift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cors\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/acoshift/cors)](https://goreportcard.com/report/github.com/acoshift/cors)\n[![GoDoc](https://godoc.org/github.com/acoshift/cors?status.svg)](https://godoc.org/github.com/acoshift/cors)\n\nCORS middleware for Golang net/http\n\n### Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/acoshift/cors\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"OK\")\n}\n\nfunc main() {\n\th := cors.New(cors.Config{\n\t\tAllowOrigins:     []string{\"localhost:8080\"},\n\t\tAllowMethods:     []string{http.MethodGet, http.MethodPost},\n\t\tAllowHeaders:     []string{\"Authorization\"},\n\t\tAllowCredentials: true,\n\t})(http.HandlerFunc(handler))\n\thttp.ListenAndServe(\":8080\", h)\n}\n```\n\nor use with [middleware](https://github.com/acoshift/middleware)\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/acoshift/cors\"\n\t\"github.com/acoshift/middleware\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"OK\")\n}\n\nfunc main() {\n\th := middleware.Chain(\n\t\tcors.New(cors.Config{\n\t\t\tAllowOrigins:     []string{\"localhost:8080\"},\n\t\t\tAllowMethods:     []string{http.MethodGet, http.MethodPost},\n\t\t\tAllowHeaders:     []string{\"Authorization\"},\n\t\t\tAllowCredentials: true,\n\t\t}),\n\t)(http.HandlerFunc(handler))\n\thttp.ListenAndServe(\":8080\", h)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fcors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facoshift%2Fcors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fcors/lists"}