{"id":42572716,"url":"https://github.com/go-humble/router","last_synced_at":"2026-01-28T21:24:10.374Z","repository":{"id":32013559,"uuid":"35584673","full_name":"go-humble/router","owner":"go-humble","description":"A router for client-side web applications written in go which compiles to javascript via gopherjs.","archived":false,"fork":false,"pushed_at":"2017-07-07T19:01:56.000Z","size":331,"stargazers_count":29,"open_issues_count":3,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-06-18T21:34:18.831Z","etag":null,"topics":["go","gopherjs"],"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/go-humble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-14T01:50:45.000Z","updated_at":"2024-06-18T21:34:18.832Z","dependencies_parsed_at":"2022-09-26T17:50:41.957Z","dependency_job_id":null,"html_url":"https://github.com/go-humble/router","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/go-humble/router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-humble","download_url":"https://codeload.github.com/go-humble/router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Frouter/sbom","scorecard":{"id":431983,"data":{"date":"2025-08-11","repo":{"name":"github.com/go-humble/router","commit":"79b5b8fa588a29a5e5dfccf0f3aa795feb6768a0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":1,"reason":"Found 4/26 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 9 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T03:35:32.188Z","repository_id":32013559,"created_at":"2025-08-19T03:35:32.189Z","updated_at":"2025-08-19T03:35:32.189Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28852375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"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":["go","gopherjs"],"created_at":"2026-01-28T21:24:09.732Z","updated_at":"2026-01-28T21:24:10.348Z","avatar_url":"https://github.com/go-humble.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Humble/Router\n=============\n\n[![Version](https://img.shields.io/badge/version-0.5.0-5272B4.svg)](https://github.com/go-humble/router/releases)\n[![GoDoc](https://godoc.org/github.com/go-humble/router?status.svg)](https://godoc.org/github.com/go-humble/router)\n\nA router for client-side web applications written in pure go which compiles to\njavascript via [gopherjs](https://github.com/gopherjs/gopherjs). Router works\ngreat as a stand-alone package or in combination with other\n[Humble](https://github.com/go-humble/humble) packages.\n\nRouter supports the following features:\n\n- Write code in pure go. It feels like go, follows go idioms, and compiles with the go tools.\n- Each route consists of a path and a handler function which is triggered when path matches.\n- Routes can have parameters, which are passed through as an argument to handler functions.\n- Router uses history.pushState and listens to the onpopstate event in browsers that support\n  it. In older browsers it automatically falls back to using a hash.\n- Router can be configured to automatically intercept link click events, triggering the appropriate\n  route instead of requesting a new page.\n\n\nBrowser Support\n---------------\n\nRouter works with IE9+ (with a\n[polyfill for typed arrays](https://github.com/inexorabletash/polyfill/blob/master/typedarray.js))\nand all other modern browsers. Router compiles to javascript via [gopherjs](https://github.com/gopherjs/gopherjs)\nand this is a gopherjs limitation.\n\nRouter is regularly tested with the latest versions of Firefox, Chrome, and Safari on Mac OS.\nEach major or minor release is tested with IE9+ and the latest versions of Firefox and Chrome\non Windows.\n\n\nInstallation\n------------\n\nInstall router like you would any other go package:\n\n```bash\ngo get github.com/go-humble/router\n```\n\nYou will also need to install gopherjs if you don't already have it. The latest\nversion is recommended. Install gopherjs with:\n\n```\ngo get -u github.com/gopherjs/gopherjs\n```\n\nYou can compile your application to javascript using the `gopherjs build`\ncommand. Run `gopherjs --help` to learn more about the gopherjs command-line\ntool.\n\n\nQuickstart Guide\n----------------\n\n### Declaring Routes\n\nDeclaring routes works similarly to other routing packages in go. Here's an example:\n\n```go\n// Create a new Router object\nr := router.New()\n// Use HandleFunc to add routes.\nr.HandleFunc(\"/people\", indexPeople)\nr.HandleFunc(\"/people/{id}\", showPerson)\n// You must call Start in order to start listening for changes\n// in the url and trigger the appropriate handler function.\nr.Start()\n```\n\nThe second argument to HandleFunc should be a router.Handler, which has the following\ndefinition:\n\n```go\ntype Handler func(context *Context)\n```\n\nAnd the Context type is defined as follows:\n\n```go\ntype Context struct {\n\t// Params is the parameters from the url as a map of names to values.\n\tParams map[string]string\n\t// Path is the path that triggered this particular route. If the hash\n\t// fallback is being used, the value of path does not include the '#'\n\t// symbol.\n\tPath string\n\t// InitialLoad is true iff this route was triggered during the initial\n\t// page load. I.e. it is true if this is the first path that the browser\n\t// was visiting when the javascript finished loading.\n\tInitialLoad bool\n}\n```\n\n### Accessing Parameters\n\nParameters are accessed via `context.Params`. If we have a route defined\nlike this:\n\n```go\nr.HandleFunc(\"/people/{id}\", showPerson)\n```\n\nAnd the path `/people/123` is triggered, then the parameters passed into the showPerson\nfunction would look like the following:\n\n```go\ncontext.Params = map[string]string{\n\t\"id\": \"123\",\n}\n```\n\nIn our showPerson function, we could access the id parameter like so:\n\n```go\nfunc showPerson(context *router.Context) {\n\tid := context.Params[\"id\"]\n\t// ...\n}\n```\n\nA path can have any number of parameters, but each parameter must be defined inside slashes.\nSo a path like `people/{id}/{action}` is supported, but `people/{id}?action={action}` is not.\nThis may change in the future.\n\n### Navigating Manually\n\nYou can trigger a route manually with the `Navigate` method:\n\n```go\n// Triger the route corresponding to \"people/{id}\"\nr.Navigate(\"people/123\")\n```\n\nArguments to `Navigate` should never contain the hash symbol. The router package will detect\nsupport for `history.pushState` and automatically fallback to using hashes if it is not supported.\n\nYou can also call the `Back` function to navigate back to the previous page.\n\n### Intercepting Link Clicks\n\nA `router.Router` can be configured to intercept link click events and trigger the appropriate route\nwith the `InterceptLinks` method. When called, the router finds links of the form `\u003ca href=\"/foo\"\u003e\u003c/a\u003e`\nand calls `router.Navigate(\"/foo\")` instead, which triggers the appropriate Handler instead of requesting\na new page from the server. Since `InterceptLinks` works by setting event listeners in the DOM, you must\ncall this function whenever the DOM is changed.\n\nAlternatively, you can set `router.ShouldInterceptLinks` to true, which will trigger the `InterceptLinks`\nmethod whenever `Start`, `Navigate`, or `Back` are called, or when the `onpopstate` event is triggered.\nEven with `ShouldInterceptLinks` set to true, you may still need to call `InterceptLinks` if you change\nthe DOM manually.\n\n\nTesting\n-------\n\nRouter uses three different types of tests.\n\n### Regular Go Tests\n\nRouter can be tested like any other go package by running `go test .` in the root directory.\nThese tests make sure that path matching functions work correctly and that parameters are passed\nthrough to handler functions, so they don't require access to a browser.\n\n### Gopherjs Tests\n\nIf you have [node.js](https://nodejs.org/) installed, router can also be tested with gopherjs by\nrunning `gopherjs test github.com/go-humble/router`. The `gopherjs test` command compiles the same\ntests as above into javascript and runs them with node.js. These tests make sure that we haven't\nbroken compatibility with gopherjs and that the code still runs properly when it is compiled to\njavascript.\n\n### Browser Tests\n\nThe third type of tests use the [karma test runner](http://karma-runner.github.io/0.12/index.html)\nto test the code running in actual browsers. It makes sure that router is able to respond to events\nand work correctly with the browser history.\n\nThe browser tests require additional dependencies:\n\n- [node.js](http://nodejs.org/) (If you didn't already install it above)\n- [karma](http://karma-runner.github.io/0.12/index.html)\n- [karma-qunit](https://github.com/karma-runner/karma-qunit)\n\nDon't forget to also install the karma command line tools with `npm install -g karma-cli`.\n\nYou will also need to install a launcher for each browser you want to test with, as well as the\nbrowsers themselves. Typically you install a karma launcher with `npm install -g karma-chrome-launcher`.\nYou can edit the config file at `karma/test-mac.conf.js` or create a new one (e.g. `karma/test-windows.conf.js`)\nif you want to change the browsers that are tested on.\n\nOnce you have installed all the dependencies, start karma with `karma start karma/test-mac.conf.js` (or\nyour customized config file, if applicable). Once karma is running, you can keep it running in between tests.\n\nNext you need to compile the test.go file to javascript so it can run in the browsers:\n\n```\ngopherjs build karma/go/router_test.go -o karma/js/router_test.js\n```\n\nFinally run the tests with `karma run karma/test-mac.conf.js` (changing the name of the config file if needed).\n\nIf you are on a unix-like operating system, you can recompile and run the tests in one go by running\nthe provided bash script: `./karma/test.sh`.\n\n\nContributing\n------------\n\nSee [CONTRIBUTING.md](https://github.com/go-humble/router/blob/master/CONTRIBUTING.md)\n\n\nLicense\n-------\n\nRouter is licensed under the MIT License. See the [LICENSE](https://github.com/go-humble/router/blob/master/LICENSE)\nfile for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-humble%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-humble%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-humble%2Frouter/lists"}