{"id":16516223,"url":"https://github.com/aphistic/negroni-requestid","last_synced_at":"2026-05-13T19:32:55.328Z","repository":{"id":57483846,"uuid":"81124815","full_name":"aphistic/negroni-requestid","owner":"aphistic","description":"Negroni middleware to add a randomly generated request ID to the request context and optionally add it as an X-Request-ID header.","archived":false,"fork":false,"pushed_at":"2018-07-11T21:31:55.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T18:17:00.648Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/aphistic.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-02-06T19:42:43.000Z","updated_at":"2018-09-21T22:59:45.000Z","dependencies_parsed_at":"2022-08-28T17:02:17.868Z","dependency_job_id":null,"html_url":"https://github.com/aphistic/negroni-requestid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aphistic/negroni-requestid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aphistic%2Fnegroni-requestid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aphistic%2Fnegroni-requestid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aphistic%2Fnegroni-requestid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aphistic%2Fnegroni-requestid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aphistic","download_url":"https://codeload.github.com/aphistic/negroni-requestid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aphistic%2Fnegroni-requestid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32997634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: 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":[],"created_at":"2024-10-11T16:20:06.789Z","updated_at":"2026-05-13T19:32:55.291Z","avatar_url":"https://github.com/aphistic.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# negroni-requestid\nNegroni middleware to add a randomly generated request ID to the request context\nand optionally add it as an X-Request-ID header.\n\n## Usage\n\n__Default Options__\n\nBy default, `negroni-requestid` will generate a UUID-based ID, store it in the\nhttp.Request's Context and write the ID to the X-Request-ID header on the\nresponse.\n```go\nn := negroni.New()\nn.Use(requestid.NewMiddleware())\n```\n\n__Custom ID Generator__\n\nIf you'd like to use a different way to generate request ID's other than a\nstandard UUID, it is possible to provide a new function to do it:\n```go\nn := negroni.New()\n\nreqmw := requestid.NewMiddleware()\nreqmw.GenerateID = func() string {\n    return \"7\"\n}\n```\n\n__Disable X- Header Output__\n\nIf you'd like to disable the X-Request-ID header being added to responses or\nyou'd like to change the header being written, you are able to set that on the\nmiddleware.  If you'd like to disable the header completely, just supply an empty\nstring:\n```go\nn := negroni.New()\n\nreqmw := requestid.NewMiddleware()\nreqmw.XHeader = \"X-My-ID\"\n// or to disable it:\nreqmw.XHeader = \"\"\n```\n\n__Retrieve ID From Context__\n\nTo retrieve the request ID from an http.Request's Context, you can use the\n`FromContext` method in the package:\n```go\nfunc handleReq(w http.ResponseWriter, req *http.Request) {\n    reqID, err := requestid.FromContext(req.Context())\n    if err != nil {\n        fmt.Printf(\"Error getting request ID: %s\\n\", err)\n    } else {\n        fmt.Printf(\"Got request ID: %s\\n\", reqID)\n    }\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faphistic%2Fnegroni-requestid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faphistic%2Fnegroni-requestid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faphistic%2Fnegroni-requestid/lists"}