{"id":23129023,"url":"https://github.com/twiny/sigma","last_synced_at":"2025-10-15T14:50:13.710Z","repository":{"id":57642599,"uuid":"437072850","full_name":"twiny/sigma","owner":"twiny","description":"a small wrapper around go-chi HTTP router.","archived":false,"fork":false,"pushed_at":"2023-10-14T11:50:52.000Z","size":11,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-17T18:39:27.215Z","etag":null,"topics":["go-chi","golang","http-router","rest-api"],"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/twiny.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-10T18:11:54.000Z","updated_at":"2024-11-04T10:44:25.000Z","dependencies_parsed_at":"2024-06-20T00:23:17.841Z","dependency_job_id":"238fe8f1-5107-45b7-a541-54c766ab119e","html_url":"https://github.com/twiny/sigma","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/twiny/sigma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fsigma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fsigma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fsigma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fsigma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twiny","download_url":"https://codeload.github.com/twiny/sigma/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fsigma/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278621842,"owners_count":26017253,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-chi","golang","http-router","rest-api"],"created_at":"2024-12-17T10:08:06.969Z","updated_at":"2025-10-06T13:57:40.350Z","avatar_url":"https://github.com/twiny.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sigma\n\na small wrapper around [go-chi](https://github.com/go-chi/chi) HTTP router.\n\n\n**NOTE**: This package is provided \"as is\" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please [create a new issue](https://github.com/twiny/sigma/issues/new).\n\n## API\nRouter methods.\n```go\n// Router\ntype Router interface {\n\tEndpoint(method, pattern string, handler http.HandlerFunc)\n\tUse(middlewares ...func(next http.Handler) http.Handler)\n\tGroup(pattern string, fn func(r Router))\n\tStatic(pattern, path string)\n\tNotFound(handler http.HandlerFunc)\n\tNotAllowed(handler http.HandlerFunc)\n\tServeHTTP(w http.ResponseWriter, r *http.Request)\n}\n```\nParam returns the url parameter from a http.Request object.\n```go\nParam(r *http.Request, key string) string\n```\n\n## Example\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/twiny/sigma\"\n)\n\nfunc main() {\n\tsrv := sigma.NewServer(\":1234\")\n\tdefer srv.Stop()\n\n\trouter := srv.NewRouter()\n\n\t// custom 404 not found handler\n\trouter.NotFound(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\tw.Write([]byte(\"404 - Not Found\"))\n\t})\n\n\t// custom 405 not allowed handler\n\trouter.NotAllowed(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.WriteHeader(http.StatusMethodNotAllowed)\n\t\tw.Write([]byte(\"405 - Method Not Allowed\"))\n\t})\n\n\t// middleware\n\trouter.Use(func(next http.Handler) http.Handler {\n\t\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tr.Header.Add(\"x-key-1\", \"main router\")\n\t\t\tnext.ServeHTTP(w, r)\n\t\t})\n\t})\n\n\t// endpoints\n\trouter.Endpoint(http.MethodGet, \"/hello/{name}\", func(w http.ResponseWriter, r *http.Request) {\n\t\tname := sigma.Param(r, \"name\")\n\t\tw.Write([]byte(\"Hello World \" + name))\n\t})\n\n\t// sub router\n\trouter.Group(\"/v1\", func(r sigma.Router) {\n\t\t// sub router middleware\n\t\tr.Use(func(next http.Handler) http.Handler {\n\t\t\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\t\tr.Header.Add(\"x-key-2\", \"sub router\")\n\t\t\t\tnext.ServeHTTP(w, r)\n\t\t\t})\n\t\t})\n\t\t//\n\t\tr.Endpoint(http.MethodGet, \"/hello/{name}\", func(w http.ResponseWriter, r *http.Request) {\n\t\t\tname := sigma.Param(r, \"name\")\n\t\t\tw.Write([]byte(\"Hello World v1 \" + name))\n\t\t})\n\t})\n\n\t// static files\n\trouter.Static(\"/web\", \"./static\")\n\n\tlog.Fatal(srv.Start())\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwiny%2Fsigma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwiny%2Fsigma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwiny%2Fsigma/lists"}