{"id":22685355,"url":"https://github.com/majidsajadi/sariaf","last_synced_at":"2025-06-11T11:41:20.645Z","repository":{"id":50085941,"uuid":"316981270","full_name":"majidsajadi/sariaf","owner":"majidsajadi","description":"Fast, simple, and lightweight HTTP router for Golang","archived":false,"fork":false,"pushed_at":"2020-12-17T05:02:54.000Z","size":12,"stargazers_count":34,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T13:53:47.947Z","etag":null,"topics":["golang","handler","http","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/majidsajadi.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":"2020-11-29T15:26:50.000Z","updated_at":"2024-03-14T19:16:36.000Z","dependencies_parsed_at":"2022-09-07T23:50:32.740Z","dependency_job_id":null,"html_url":"https://github.com/majidsajadi/sariaf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majidsajadi%2Fsariaf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majidsajadi%2Fsariaf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majidsajadi%2Fsariaf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majidsajadi%2Fsariaf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/majidsajadi","download_url":"https://codeload.github.com/majidsajadi/sariaf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248623213,"owners_count":21135206,"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":["golang","handler","http","router"],"created_at":"2024-12-09T22:14:32.087Z","updated_at":"2025-04-12T19:36:03.965Z","avatar_url":"https://github.com/majidsajadi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sariaf\n\nFast, simple and lightweight HTTP router for golang\n\n## Install\n\n`go get -u github.com/majidsajadi/sariaf`\n\n## Features\n\n- **Lightweight**\n- **compatible with net/http**\n- **No external dependencies**\n- **Panic handler**\n- **Custom not found handler**\n- **No external dependencies**\n- **Middleware support**\n- **URL parameters**\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/majidsajadi/sariaf\"\n)\n\nfunc main() {\n    r := sariaf.New()\n\n    r.Get(\"/\", func(w http.ResponseWriter, r *http.Request) {\n        w.Write([]byte(\"welcome\"))\n    })\n\n    http.ListenAndServe(\":3000\", r)\n}\n```\n\n## Advanced Usage \n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/majidsajadi/sariaf\"\n)\n\nfunc main() {\n\trouter := sariaf.New()\n\n\trouter.SetNotFound(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\tfmt.Fprint(w, \"Not Found\")\n\t})\n\n\trouter.SetPanicHandler(func(w http.ResponseWriter, r *http.Request, err interface{}) {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Println(\"error:\", err)\n\t\tfmt.Fprint(w, \"Internal Server Error\")\n\t})\n\n\trouter.GET(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Write([]byte(\"Hello World\"))\n\t})\n\n\trouter.GET(\"/posts\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Write([]byte(\"GET: Get All Posts\"))\n\t})\n\n\trouter.GET(\"/posts/:id\", func(w http.ResponseWriter, r *http.Request) {\n\t\tparams, _ := sariaf.GetParams(r)\n\t\tw.Write([]byte(\"GET: Get Post With ID:\" + params[\"id\"]))\n\t})\n\n\trouter.POST(\"/posts\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Write([]byte(\"POST: Create New Post\"))\n\t})\n\n\trouter.PATCH(\"/posts/:id\", func(w http.ResponseWriter, r *http.Request) {\n\t\tparams, _ := sariaf.GetParams(r)\n\t\tw.Write([]byte(\"PATCH: Update Post With ID:\" + params[\"id\"]))\n\t})\n\n\trouter.PUT(\"/posts/:id\", func(w http.ResponseWriter, r *http.Request) {\n\t\tparams, _ := sariaf.GetParams(r)\n\t\tw.Write([]byte(\"PUT: Update Post With ID:\" + params[\"id\"]))\n\t})\n\n\trouter.DELETE(\"/posts/:id\", func(w http.ResponseWriter, r *http.Request) {\n\t\tparams, _ := sariaf.GetParams(r)\n\t\tw.Write([]byte(\"DELETE: Delete Post With ID:\" + params[\"id\"]))\n\t})\n\n\trouter.GET(\"/error\", func(w http.ResponseWriter, r *http.Request) {\n\t\tpanic(\"Some Error Message\")\n\t})\n\n\tlog.Fatal(http.ListenAndServe(\":8181\", router))\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmajidsajadi%2Fsariaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmajidsajadi%2Fsariaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmajidsajadi%2Fsariaf/lists"}