{"id":22385281,"url":"https://github.com/acoshift/prefixhandler","last_synced_at":"2026-04-27T21:32:09.100Z","repository":{"id":57480559,"uuid":"125173682","full_name":"acoshift/prefixhandler","owner":"acoshift","description":"Path Prefix Handler","archived":false,"fork":false,"pushed_at":"2018-03-14T15:21:29.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-13T16:54:23.980Z","etag":null,"topics":["golang","handler"],"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/acoshift.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":"2018-03-14T07:37:19.000Z","updated_at":"2018-03-15T18:16:24.000Z","dependencies_parsed_at":"2022-09-26T17:41:14.269Z","dependency_job_id":null,"html_url":"https://github.com/acoshift/prefixhandler","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/acoshift/prefixhandler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fprefixhandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fprefixhandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fprefixhandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fprefixhandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acoshift","download_url":"https://codeload.github.com/acoshift/prefixhandler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fprefixhandler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32356598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["golang","handler"],"created_at":"2024-12-05T01:22:40.737Z","updated_at":"2026-04-27T21:32:09.083Z","avatar_url":"https://github.com/acoshift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prefixhandler\n\n[![Build Status](https://travis-ci.org/acoshift/prefixhandler.svg?branch=master)](https://travis-ci.org/acoshift/prefixhandler)\n[![Coverage Status](https://coveralls.io/repos/github/acoshift/prefixhandler/badge.svg?branch=master)](https://coveralls.io/github/acoshift/prefixhandler?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/acoshift/prefixhandler)](https://goreportcard.com/report/github.com/acoshift/prefixhandler)\n[![GoDoc](https://godoc.org/github.com/acoshift/prefixhandler?status.svg)](https://godoc.org/github.com/acoshift/prefixhandler)\n\nPath Prefix Handler for http.ServeMux\n\n## Example\n\n```go\npackage main\n\nimport (\n    \"io\"\n    \"net/http\"\n\n    \"github.com/acoshift/prefixhandler\"\n)\n\nfunc main() {\n    mux := http.NewServeMux()\n\n    itemMux := http.NewServeMux()\n    itemMux.Handle(\"/\", http.HandlerFunc(itemDetail))\n    itemMux.Handle(\"/edit\", http.HandlerFunc(itemEdit))\n\n    mux.Handle(\"/item\", http.NotFoundHandler())\n    mux.Handle(\"/item/\", prefixhandler.New(\"/item\", \"item_id\", itemMux))\n\n    http.ListenAndServe(\":8080\", mux)\n}\n\nfunc itemDetail(w http.ResponseWriter, r *http.Request) {\n    if r.URL.Path != \"/\" {\n        http.NotFound(w, r)\n        return\n    }\n\n    itemID := prefixhandler.Get(r.Context(), \"item_id\")\n    // or\n    // itemID = r.Context().Value(\"item_id\").(string)\n\n    if itemID == \"\" {\n        http.NotFound(w, r)\n        return\n    }\n\n    io.WriteString(w, \"Item: \"+itemID)\n}\n\nfunc itemEdit(w http.ResponseWriter, r *http.Request) {\n    itemID := prefixhandler.Get(r.Context(), \"item_id\")\n    io.WriteString(w, \"Editing Item: \"+itemID)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fprefixhandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facoshift%2Fprefixhandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fprefixhandler/lists"}