{"id":16735765,"url":"https://github.com/mrz1836/go-api-router","last_synced_at":"2025-06-15T14:04:28.542Z","repository":{"id":35685350,"uuid":"197233817","full_name":"mrz1836/go-api-router","owner":"mrz1836","description":":globe_with_meridians: A lightweight API middleware for Julien Schmidt's router: cors, logging, and standardized error handling","archived":false,"fork":false,"pushed_at":"2025-03-31T19:37:07.000Z","size":724,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T20:33:58.208Z","etag":null,"topics":["api","api-router","go","golang","gomod","gomodule","httprouter","logging","middleware","newrelic","router"],"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/mrz1836.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mrz1836","custom":"https://mrz1818.com/?tab=tips\u0026utm_source=github\u0026utm_medium=sponsor-link\u0026utm_campaign=go-api-router\u0026utm_term=go-api-router\u0026utm_content=go-api-router"}},"created_at":"2019-07-16T16:56:09.000Z","updated_at":"2025-03-31T19:37:05.000Z","dependencies_parsed_at":"2023-10-17T00:01:33.535Z","dependency_job_id":"9fa5bd4d-7a61-497c-8e4b-eba0a1471143","html_url":"https://github.com/mrz1836/go-api-router","commit_stats":null,"previous_names":[],"tags_count":98,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrz1836%2Fgo-api-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrz1836%2Fgo-api-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrz1836%2Fgo-api-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrz1836%2Fgo-api-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrz1836","download_url":"https://codeload.github.com/mrz1836/go-api-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217179,"owners_count":21066633,"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":["api","api-router","go","golang","gomod","gomodule","httprouter","logging","middleware","newrelic","router"],"created_at":"2024-10-13T00:07:13.139Z","updated_at":"2025-06-15T14:04:28.530Z","avatar_url":"https://github.com/mrz1836.png","language":"Go","funding_links":["https://github.com/sponsors/mrz1836","https://mrz1818.com/?tab=tips\u0026utm_source=github\u0026utm_medium=sponsor-link\u0026utm_campaign=go-api-router\u0026utm_term=go-api-router\u0026utm_content=go-api-router"],"categories":[],"sub_categories":[],"readme":"# go-api-router\n\u003e Lightweight API [httprouter](https://github.com/julienschmidt/httprouter) middleware: cors, logging, and standardized error handling.\n\n[![Release](https://img.shields.io/github/v/release/mrz1836/go-api-router?logo=github\u0026style=flat\u0026v=4)](https://github.com/mrz1836/go-api-router/releases)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/mrz1836/go-api-router/run-tests.yml?branch=master\u0026logo=github\u0026v=4)](https://github.com/mrz1836/go-api-router/actions)\n[![Report](https://goreportcard.com/badge/github.com/mrz1836/go-api-router?style=flat\u0026v=4)](https://goreportcard.com/report/github.com/mrz1836/go-api-router)\n[![codecov](https://codecov.io/gh/mrz1836/go-api-router/branch/master/graph/badge.svg?v=4)](https://codecov.io/gh/mrz1836/go-api-router)\n[![Go](https://img.shields.io/github/go-mod/go-version/mrz1836/go-api-router?v=4)](https://golang.org/)\n\u003cbr\u003e\n[![Sponsor](https://img.shields.io/badge/sponsor-MrZ-181717.svg?logo=github\u0026style=flat\u0026v=4)](https://github.com/sponsors/mrz1836)\n[![Donate](https://img.shields.io/badge/donate-bitcoin-ff9900.svg?logo=bitcoin\u0026style=flat\u0026v=4)](https://mrz1818.com/?tab=tips\u0026utm_source=github\u0026utm_medium=sponsor-link\u0026utm_campaign=go-api-router\u0026utm_term=go-api-router\u0026utm_content=go-api-router)\n\n\u003cbr/\u003e\n\n## Table of Contents\n- [Installation](#installation)\n- [Documentation](#documentation)\n- [Examples \u0026 Tests](#examples--tests)\n- [Benchmarks](#benchmarks)\n- [Code Standards](#code-standards)\n- [Usage](#usage)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003cbr/\u003e\n\n## Installation\n\n**go-api-router** requires a [supported release of Go](https://golang.org/doc/devel/release.html#policy).\n```shell script\ngo get -u github.com/mrz1836/go-api-router\n```\n\n\u003cbr/\u003e\n\n## Documentation\nView the generated [documentation](https://pkg.go.dev/github.com/mrz1836/go-api-router)\n\n[![GoDoc](https://godoc.org/github.com/mrz1836/go-api-router?status.svg\u0026style=flat)](https://pkg.go.dev/github.com/mrz1836/go-api-router)\n\n### Features\n- Uses the fastest router: Julien Schmidt's [httprouter](https://github.com/julienschmidt/httprouter)\n- Uses gofr's [uuid](https://github.com/gofrs/uuid) package to guarantee unique request ids\n- Uses MrZ's [go-logger](https://github.com/mrz1836/go-logger) for either local or remote logging via [Log Entries (Rapid7)](https://www.rapid7.com/products/insightops/)\n- Uses MrZ's [go-parameters](https://github.com/mrz1836/go-parameters) for parsing any type of incoming parameter with ease\n- Optional: [NewRelic](https://docs.newrelic.com/docs/agents/go-agent/get-started/go-agent-compatibility-requirements/) support!\n- Added basic middleware support from Rileyr's [middleware](https://github.com/rileyr/middleware)\n- Optional: [JWT Authentication](https://github.com/golang-jwt/jwt) (middleware)\n- Added additional CORS functionality\n- Standardized error responses for API requests\n- Centralized logging on all requests (requesting user info and request time)\n- Custom response writer for Etag and cache support\n- `GetClientIPAddress()` safely detects IP addresses behind load balancers\n- `GetParams()` parses parameters only once\n- `FilterMap()` removes any confidential parameters from logs\n- ...and more!\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003ePackage Dependencies\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\n- Julien Schmidt's [httprouter](https://github.com/julienschmidt/httprouter) package\n- Rileyr's [middleware](https://github.com/rileyr/middleware) package\n- gofrs [uuid](https://github.com/gofrs/uuid) package\n- MrZ's [go-logger](https://github.com/mrz1836/go-logger) and [go-parameters](https://github.com/mrz1836/go-parameters) package\n- NewRelic's [go-agent](https://github.com/newrelic/go-agent)\n- Golang's [golang-jwt](https://github.com/golang-jwt/jwt)\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eLibrary Deployment\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\n[goreleaser](https://github.com/goreleaser/goreleaser) for easy binary or library deployment to GitHub and can be installed via: `brew install goreleaser`.\n\nThe [.goreleaser.yml](.goreleaser.yml) file is used to configure [goreleaser](https://github.com/goreleaser/goreleaser).\n\nUse `make release-snap` to create a snapshot version of the release, and finally `make release` to ship to production.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eMakefile Commands\u003c/code\u003e\u003c/strong\u003e\u003c/summary\u003e\n\u003cbr/\u003e\n\nView all `makefile` commands\n```shell script\nmake help\n```\n\nList of all current commands:\n```text\nall                  Runs lint, test and vet\nclean                Remove previous builds and any test cache data\nclean-mods           Remove all the Go mod cache\ncoverage             Shows the test coverage\ngodocs               Sync the latest tag with GoDocs\nhelp                 Show this help message\ninstall              Install the application\ninstall-go           Install the application (Using Native Go)\nlint                 Run the golangci-lint application (install if not found)\nrelease              Full production release (creates release in Github)\nrelease              Runs common.release then runs godocs\nrelease-snap         Test the full release (build binaries)\nrelease-test         Full production test release (everything except deploy)\nreplace-version      Replaces the version in HTML/JS (pre-deploy)\nrun-examples         Runs all the examples\ntag                  Generate a new tag and push (tag version=0.0.0)\ntag-remove           Remove a tag if found (tag-remove version=0.0.0)\ntag-update           Update an existing tag to current commit (tag-update version=0.0.0)\ntest                 Runs vet, lint and ALL tests\ntest-ci              Runs all tests via CI (exports coverage)\ntest-ci-no-race      Runs all tests via CI (no race) (exports coverage)\ntest-ci-short        Runs unit tests via CI (exports coverage)\ntest-short           Runs vet, lint and tests (excludes integration tests)\nuninstall            Uninstall the application (and remove files)\nupdate-linter        Update the golangci-lint package (macOS only)\nvet                  Run the Go vet application\n```\n\u003c/details\u003e\n \n\u003cbr/\u003e\n\n## Examples \u0026 Tests\nAll unit tests and [examples](examples) run via [GitHub Actions](https://github.com/mrz1836/go-api-router/actions) and\n use [Go version 1.23.x](https://golang.org/doc/go1.23). View the [configuration file](.github/workflows/run-tests.yml).\n\nRun all tests (including integration tests)\n```shell script\nmake test\n```\n\nRun tests (excluding integration tests)\n```shell script\nmake test-short\n```\n\nRun the examples:\n```shell script\nmake run-examples\n```\n\n\u003cbr/\u003e\n\n## Benchmarks\nRun the Go benchmarks:\n```shell script\nmake bench\n```\n\n\u003cbr/\u003e\n\n## Code Standards\nRead more about this Go project's [code standards](.github/CODE_STANDARDS.md).\n\n\u003cbr/\u003e\n\n## Usage\nView the [examples](examples/examples.go)\n\nBasic implementation:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/julienschmidt/httprouter\"\n\t\"github.com/mrz1836/go-api-router\"\n\t\"github.com/mrz1836/go-logger\"\n)\n\nfunc main() {\n\t// Load the router \u0026 middleware\n\trouter := apirouter.New()\n\n\t// Set the main index page (navigating to slash)\n\trouter.HTTPRouter.GET(\"/\", router.Request(index))\n\n\t// Serve the router!\n\tlogger.Fatalln(http.ListenAndServe(\":3000\", router.HTTPRouter))\n}\n\nfunc index(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {\n\t_, _ = fmt.Fprint(w, \"This is a simple route example!\")\n}\n```\n\n\u003cbr/\u003e\n\n## Maintainers\n| [\u003cimg src=\"https://github.com/mrz1836.png\" height=\"50\" alt=\"MrZ\" /\u003e](https://github.com/mrz1836) |\n|:------------------------------------------------------------------------------------------------:|\n|                                [MrZ](https://github.com/mrz1836)                                 |\n\n\n\u003cbr/\u003e\n\n## Contributing\nView the [contributing guidelines](.github/CONTRIBUTING.md) and please follow the [code of conduct](.github/CODE_OF_CONDUCT.md).\n\n### How can I help?\nAll kinds of contributions are welcome :raised_hands:! \nThe most basic way to show your support is to star :star2: the project, or to raise issues :speech_balloon:. \nYou can also support this project by [becoming a sponsor on GitHub](https://github.com/sponsors/mrz1836) :clap: \nor by making a [**bitcoin donation**](https://mrz1818.com/?tab=tips\u0026utm_source=github\u0026utm_medium=sponsor-link\u0026utm_campaign=go-api-router\u0026utm_term=go-api-router\u0026utm_content=go-api-router) to ensure this journey continues indefinitely! :rocket:\n\n[![Stars](https://img.shields.io/github/stars/mrz1836/go-api-router?label=Please%20like%20us\u0026style=social)](https://github.com/mrz1836/go-api-router/stargazers)\n\n\u003cbr/\u003e\n\n## License\n[![License](https://img.shields.io/github/license/mrz1836/go-api-router.svg?style=flat\u0026v=1)](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrz1836%2Fgo-api-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrz1836%2Fgo-api-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrz1836%2Fgo-api-router/lists"}