{"id":37161975,"url":"https://github.com/dmytrohridin/correlation-id","last_synced_at":"2026-01-14T19:16:49.808Z","repository":{"id":41788745,"uuid":"482551211","full_name":"dmytrohridin/correlation-id","owner":"dmytrohridin","description":"Golang http handler that can be used as middleware to generate correlation id","archived":false,"fork":false,"pushed_at":"2022-04-28T21:07:10.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T19:21:50.798Z","etag":null,"topics":["correlation","golang","microservices"],"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/dmytrohridin.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":"2022-04-17T14:50:35.000Z","updated_at":"2023-02-16T12:16:19.000Z","dependencies_parsed_at":"2022-09-26T21:01:30.663Z","dependency_job_id":null,"html_url":"https://github.com/dmytrohridin/correlation-id","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dmytrohridin/correlation-id","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrohridin%2Fcorrelation-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrohridin%2Fcorrelation-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrohridin%2Fcorrelation-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrohridin%2Fcorrelation-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmytrohridin","download_url":"https://codeload.github.com/dmytrohridin/correlation-id/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrohridin%2Fcorrelation-id/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28432104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["correlation","golang","microservices"],"created_at":"2026-01-14T19:16:48.957Z","updated_at":"2026-01-14T19:16:49.801Z","avatar_url":"https://github.com/dmytrohridin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Correlation Id [![Build Status](https://github.com/dmytrohridin/correlation-id/workflows/build/badge.svg)](https://github.com/dmytrohridin/correlation-id/actions) [![godoc](https://godoc.org/github.com/dmytrohridin/correlation-id?status.svg)](https://godoc.org/github.com/dmytrohridin/correlation-id)\nCorrelations Id is used in distributed applications to trace requests across multiple services. This package provides a lightweight correlation id middlware. Request headers are checked for a correlation id. If found or generated, this correlation id is attached to the request context which can be used to access the current correlation id where it is required for logging etc. Based on middleware settings correlation id can be returned with response headers.\n\n## Install and update\n\n`go get -u github.com/dmytrohridin/correlation-id`\n\n## Get Correlation Id value\nTo get correlation id value use `FromContext` function.\n```go\nid := correlationid.FromContext(req.Context())\n``` \n\n## HeaderName setting\nBy default `Correlation-Id` key used as header name. Behavior can be overridden.\n```go\nmiddleware := correlationid.New()\nmiddleware.HeaderName = \"Request-Id\"\n```\n\n## IdGenerator setting\nBy default [google/uuid package](https://github.com/google/uuid) is used for correlation id when `Correlation-Id` header is not included in request headers. Behavior can be overridden by applying a custom function.\n```go\nmiddleware := correlationid.New()\nmiddleware.IdGenerator = func() string {\n    return \"any_id\"\n}\n```\n\n## IncludeInResponse setting\nBy default `Correlation-Id` is sent in response header. Behavior can be overridden.\n```go\nmiddleware := correlationid.New()\nmiddleware.IncludeInResponse = false\n```\n\n## EnforceHeader setting\nBy default `Correlation-Id` is not required in request headers. Behavior can be overridden.\n```go\nmiddleware := correlationid.New()\nmiddleware.EnforceHeader = true\n```\nIf header is enforced and client does not send it - `BadRequest` will be returned.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmytrohridin%2Fcorrelation-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmytrohridin%2Fcorrelation-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmytrohridin%2Fcorrelation-id/lists"}