{"id":13794068,"url":"https://github.com/gin-contrib/location","last_synced_at":"2025-06-13T18:39:37.342Z","repository":{"id":7035949,"uuid":"56003272","full_name":"gin-contrib/location","owner":"gin-contrib","description":"gin middleware to expose the server's hostname and scheme","archived":false,"fork":false,"pushed_at":"2024-05-03T04:07:44.000Z","size":92,"stargazers_count":89,"open_issues_count":3,"forks_count":20,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-05-03T13:20:04.804Z","etag":null,"topics":[],"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/gin-contrib.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":"2016-04-11T19:58:08.000Z","updated_at":"2024-06-13T07:21:46.761Z","dependencies_parsed_at":"2023-02-17T01:31:52.783Z","dependency_job_id":"b1909c76-6c54-493f-a6eb-d0e22c985fe5","html_url":"https://github.com/gin-contrib/location","commit_stats":null,"previous_names":["drone/gin-location"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Flocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Flocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Flocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Flocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gin-contrib","download_url":"https://codeload.github.com/gin-contrib/location/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253816751,"owners_count":21968877,"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":[],"created_at":"2024-08-03T23:00:35.307Z","updated_at":"2025-05-12T20:31:22.658Z","avatar_url":"https://github.com/gin-contrib.png","language":"Go","readme":"# location\n\n[![Run Tests](https://github.com/gin-contrib/location/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/gin-contrib/location/actions/workflows/go.yml)\n[![codecov](https://codecov.io/gh/gin-contrib/location/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-contrib/location)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gin-contrib/location)](https://goreportcard.com/report/github.com/gin-contrib/location)\n[![GoDoc](https://godoc.org/github.com/gin-contrib/location?status.svg)](https://godoc.org/github.com/gin-contrib/location)\n\nThis Gin middleware can be used to automatically find and expose the server's\nhostname and scheme by inspecting information in the incoming `http.Request`.\nThe alternative to this plugin would be explicitly providing such information to\nthe server as a command line argument or environment variable.\n\n## Usage\n\n### Start using it\n\nDownload and install it:\n\n```bash\ngo get github.com/gin-contrib/location\n```\n\nImport it in your code:\n\n```go\nimport \"github.com/gin-contrib/location\"\n```\n\n### Default\n\n```go\npackage main\n\nimport (\n  \"github.com/gin-contrib/location\"\n  \"github.com/gin-gonic/gin\"\n)\n\nfunc main() {\n  router := gin.Default()\n\n  // configure to automatically detect scheme and host\n  // - use http when default scheme cannot be determined\n  // - use localhost:8080 when default host cannot be determined\n  router.Use(location.Default())\n\n  router.GET(\"/\", func(c *gin.Context) {\n    url := location.Get(c)\n\n    // url.Scheme\n    // url.Host\n    // url.Path\n  })\n\n  router.Run()\n}\n```\n\n### Custom\n\n```go\npackage main\n\nimport (\n  \"github.com/gin-contrib/location\"\n  \"github.com/gin-gonic/gin\"\n)\n\nfunc main() {\n  router := gin.Default()\n\n  // configure to automatically detect scheme and host with\n  // fallback to https://foo.com/base\n  // - use https when default scheme cannot be determined\n  // - use foo.com when default host cannot be determined\n  // - include /base as the path\n  router.Use(location.New(location.Config{\n    Scheme: \"https\",\n    Host: \"foo.com\",\n    Base: \"/base\",\n    Headers: location.Headers{Scheme: \"X-Forwarded-Proto\", Host: \"X-Forwarded-For\"},\n  }))\n\n  router.GET(\"/\", func(c *gin.Context) {\n    url := location.Get(c)\n\n    // url.Scheme\n    // url.Host\n    // url.Path\n  })\n\n  router.Run()\n}\n```\n\n## Contributing\n\nFork -\u003e Patch -\u003e Push -\u003e Pull Request\n\n## License\n\nMIT\n","funding_links":[],"categories":["Middlewares","Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-contrib%2Flocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgin-contrib%2Flocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-contrib%2Flocation/lists"}