{"id":20051777,"url":"https://github.com/golangtoolkits/grrt","last_synced_at":"2025-05-05T11:31:55.444Z","repository":{"id":65566761,"uuid":"590572143","full_name":"GolangToolKits/grrt","owner":"GolangToolKits","description":"GRRT (Go Request RouTer) is a direct replacement for gorilla/mux. It has built-in CORS, path variables and method based routing.","archived":false,"fork":false,"pushed_at":"2023-03-22T00:50:58.000Z","size":83,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T22:23:10.374Z","etag":null,"topics":["cors","go","golang","gorilla","gorilla-mux","gorilla-sessions","mux","mux-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/GolangToolKits.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":"2023-01-18T18:08:20.000Z","updated_at":"2024-07-15T02:04:11.000Z","dependencies_parsed_at":"2024-06-20T06:07:56.661Z","dependency_job_id":null,"html_url":"https://github.com/GolangToolKits/grrt","commit_stats":{"total_commits":64,"total_committers":1,"mean_commits":64.0,"dds":0.0,"last_synced_commit":"74617c7cd5df2ac58b7815da6e93e72e1cd3f424"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GolangToolKits%2Fgrrt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GolangToolKits%2Fgrrt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GolangToolKits%2Fgrrt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GolangToolKits%2Fgrrt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GolangToolKits","download_url":"https://codeload.github.com/GolangToolKits/grrt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252489085,"owners_count":21756262,"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":["cors","go","golang","gorilla","gorilla-mux","gorilla-sessions","mux","mux-router"],"created_at":"2024-11-13T12:05:50.875Z","updated_at":"2025-05-05T11:31:55.182Z","avatar_url":"https://github.com/GolangToolKits.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GRRT (Go Request RouTer)\n\nGRRT (Go Request RouTer) is a direct replacement for the archived gorilla/mux.\nIt has built-in CORS and Method based routing.\n\n\n## Replaces gorilla/mux with one line of code\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=GolangToolKits_grrt\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=GolangToolKits_grrt)\n[![CircleCI](https://circleci.com/gh/GolangToolKits/grrt.svg?style=svg)](https://circleci.com/gh/GolangToolKits/grrt)\n[![Go Report Card](https://goreportcard.com/badge/github.com/GolangToolKits/grrt)](https://goreportcard.com/report/github.com/GolangToolKits/grrt)\n\n\n## Features\n\n- Request Routing\n- Method Based Routing\n- CORS\n\n\n\n#### [Full REST Service Example Project](https://github.com/GolangToolKits/grrtRouterRestExample)\n\n#### [Full Web Example Project](https://github.com/GolangToolKits/grrtRouterWebSiteExample)\n\n\n\n\nPackage `GolangToolKits/grrt` implements a request router and dispatcher for handling incoming requests to their associated handler.\n\nThe name mux stands for \"HTTP request multiplexer\". Like the standard `http.ServeMux`, `grrt.Router` matches incoming requests against a list of registered routes and calls a handler for the route that matches the URL. The main features are:\n\n\n* Replaces gorilla/mux with one line of code\n* It implements the `http.Handler` interface so it is compatible with the standard `http.ServeMux`.\n* URL hosts, paths and query values can be handled.\n* Path variable can be used instead of query parameters with ease.\n* Method base routing is easy\n* CORS is built in with no need for additional modules.\n\n\n---\n\n* [Install](#install)\n* [Examples REST Service](#RestExample)\n* [Examples Web Server](#WebExample)\n\n\n---\n\n\n## Install\n\n\n```sh\ngo get -u github.com/GolangToolKits/grrt\n\n```\n\n\n## RestExample\n\n#### [REST Service Full Example](https://github.com/GolangToolKits/grrtRouterRestExample)\n\n```go\nimport(\n\n    \"fmt\"\n    \"net/http\"\n    \"os\"\n    \"strconv\"\n    ph \"github.com/GolangToolKits/grrtRouterRestExample/handlers\"\n    mux \"github.com/GolangToolKits/grrt\"\n)\n\n\nfunc main() {\n\n\tvar sh ph.StoreHandler //see the example project for the full code\n\n\th := sh.New()\n\n\trouter := mux.NewRouter()\n\trouter.EnableCORS()\n\trouter.CORSAllowCredentials()\n\trouter.SetCorsAllowedHeaders(\"X-Requested-With, Content-Type, api-key, customer-key, Origin\")\n\trouter.SetCorsAllowedOrigins(\"*\")\n\trouter.SetCorsAllowedMethods(\"GET, DELETE, POST, PUT\")\n\n\tport := \"3000\"\n\tenvPort := os.Getenv(\"PORT\")\n\tif envPort != \"\" {\n\t\tportInt, _ := strconv.Atoi(envPort)\n\t\tif portInt != 0 {\n\t\t\tport = envPort\n\t\t}\n\t}\n\n\trouter.HandleFunc(\"/rs/product/get/{id}\", h.GetProduct).Methods(\"GET\")\n\trouter.HandleFunc(\"/rs/product/get/{id}/{sku}\", h.GetProductWithIDAndSku).Methods(\"GET\")\n\trouter.HandleFunc(\"/rs/products\", h.GetProducts).Methods(\"GET\")\n\trouter.HandleFunc(\"/rs/product/add\", h.AddProduct).Methods(\"POST\")\n\trouter.HandleFunc(\"/rs/product/update\", h.UpdateProduct).Methods(\"PUT\")\n\tfmt.Println(\"running on Port:\", port)\n\thttp.ListenAndServe(\":\"+port, (router))\n\n}\n```\n\n\n## WebExample\n\n#### [Web Full Example](https://github.com/GolangToolKits/grrtRouterWebSiteExample)\n\n```go\n\nimport (\n\t\"fmt\"\n\t\"html/template\"\n\t\"net/http\"\n\t\"os\"\n\t\"strconv\"\n\n\tmux \"github.com/GolangToolKits/grrt\"\n\thd \"github.com/GolangToolKits/grrtRouterWebSiteExample/handlers\"\n)\n\nfunc main() {\n\n\tvar sh hd.SiteHandler\n\n\tsh.Templates = template.Must(template.ParseFiles(\"./static/index.html\",\n\t\t\"./static/product.html\", \"./static/addProduct.html\"))\n\n\trouter := mux.NewRouter()\n\n\th := sh.New()\n\n\trouter.HandleFunc(\"/\", h.Index).Methods(\"GET\")\n\trouter.HandleFunc(\"/product/{id}/{sku}\", h.ViewProduct).Methods(\"GET\")\n\trouter.HandleFunc(\"/addProduct\", h.AddProduct).Methods(\"POST\")\n\n\tport := \"8080\"\n\tenvPort := os.Getenv(\"PORT\")\n\tif envPort != \"\" {\n\t\tportInt, _ := strconv.Atoi(envPort)\n\t\tif portInt != 0 {\n\t\t\tport = envPort\n\t\t}\n\t}\n\n\trouter.PathPrefix(\"/\").Handler(http.FileServer(http.Dir(\"./static/\")))\n\n\tfmt.Println(\"Web UI is running on port 8080!\")\n\n\thttp.ListenAndServe(\":\"+port, (router))\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolangtoolkits%2Fgrrt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolangtoolkits%2Fgrrt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolangtoolkits%2Fgrrt/lists"}