{"id":22385238,"url":"https://github.com/acoshift/redirecthttps","last_synced_at":"2025-07-31T04:32:57.900Z","repository":{"id":64304520,"uuid":"99535897","full_name":"acoshift/redirecthttps","owner":"acoshift","description":"Redirect HTTP to HTTPS middleware","archived":false,"fork":false,"pushed_at":"2017-10-11T05:45:23.000Z","size":19,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T20:12:38.271Z","etag":null,"topics":["golang","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}},"created_at":"2017-08-07T04:15:17.000Z","updated_at":"2019-07-19T12:53:14.000Z","dependencies_parsed_at":"2023-01-15T10:15:44.823Z","dependency_job_id":null,"html_url":"https://github.com/acoshift/redirecthttps","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/acoshift/redirecthttps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fredirecthttps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fredirecthttps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fredirecthttps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fredirecthttps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acoshift","download_url":"https://codeload.github.com/acoshift/redirecthttps/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fredirecthttps/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267988336,"owners_count":24176993,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["golang","middleware"],"created_at":"2024-12-05T01:22:22.929Z","updated_at":"2025-07-31T04:32:57.656Z","avatar_url":"https://github.com/acoshift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"logo@2x.png\" alt=\"Logo\" width='45%' /\u003e\n\n  \u003ch2\u003eRedirectHTTPS: HTTPS Redirection Middleware\u003c/h2\u003e\n  \u003cp\u003eA minimalistic middleware that redirects all network traffic from the insecure HTTP protocol to the HTTPS transport, all written in Go\u003cp\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/acoshift/redirecthttps?style=flat-square)](https://goreportcard.com/report/github.com/acoshift/redirecthttps)\n[![Build Status](https://travis-ci.org/acoshift/redirecthttps.svg?branch=master)](https://travis-ci.org/acoshift/redirecthttps)\n[![Coverage Status](https://coveralls.io/repos/github/acoshift/redirecthttps/badge.svg?branch=master)](https://coveralls.io/github/acoshift/redirecthttps?branch=master)\n[![github issues](https://img.shields.io/github/issues/acoshift/redirecthttps.svg?style=flat-square)](https://github.com/acoshift/redirecthttps/issues?q=is%3Aopen+is%3Aissue)\n[![release](https://img.shields.io/github/release/acoshift/redirecthttps.svg?style=flat-square)](https://github.com/acoshift/redirecthttps/releases)\n[![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://gitter.im/acoshift)\n[![license](https://img.shields.io/github/license/acoshift/redirecthttps.svg?style=flat-square)]()\n\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n### Installation\n\n`go get github.com/acoshift/redirecthttps`\n\n### Usage Example\n\nThis middleware can be applied in the middleware chain, as follows:\n\n```\nmiddlewares := middleware.Chain(\n  // We can put our redirection middleware right here.\n  redirecthttps.New(redirecthttps.Config{\n    // The redirection mode can be specified below.\n    Mode: redirecthttps.OnlyProxy\n  }),\n)\n\nmux.Handle(\"/\", middlewares(app.Handler()))\n```\n\n### Configuration: Redirection Modes\n\nThere are three redirection modes, which can be specified before instantiating the middleware.\n\nFirst, the `OnlyConnectionState` Mode, which only checks the connection state from request.TLS, and perform the redirection if TLS is not present in the request.\n\nSecond, the `OnlyProxy` Mode, which only checks the X-Forwarded-Proto header from the request in order to determine if it's using plain HTTP or not. If so, perform the redirection.\n\nFinally, the `All` Mode, which checks both the X-Forwarded-Proto Header AND the request.TLS variable.\n\n### Contribution\n\nIf you found an issue in this library, please file file an issue at https://github.com/acoshift/redirecthttps/issues.\n\nIf you wanted to help improve this middleware, feel free to fork this project and submit a pull request through GitHub. Thanks!\n\n### License\n\nMIT License\n\nCopyright (c) 2017 Thanatat Tamtan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fredirecthttps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facoshift%2Fredirecthttps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fredirecthttps/lists"}