{"id":18051788,"url":"https://github.com/joegasewicz/gorilla-controllers","last_synced_at":"2025-04-10T18:15:01.701Z","repository":{"id":46024708,"uuid":"410616564","full_name":"joegasewicz/gorilla-controllers","owner":"joegasewicz","description":"Use controllers with the  Gorilla Mux library","archived":false,"fork":false,"pushed_at":"2021-11-19T11:48:29.000Z","size":28,"stargazers_count":8,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T13:34:12.703Z","etag":null,"topics":["controllers","gorilla","gorilla-mux","mvc","templates"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/joegasewicz/gorilla-controllers","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/joegasewicz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-09-26T17:25:03.000Z","updated_at":"2025-02-27T09:53:25.000Z","dependencies_parsed_at":"2022-08-28T09:31:13.801Z","dependency_job_id":null,"html_url":"https://github.com/joegasewicz/gorilla-controllers","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joegasewicz%2Fgorilla-controllers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joegasewicz%2Fgorilla-controllers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joegasewicz%2Fgorilla-controllers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joegasewicz%2Fgorilla-controllers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joegasewicz","download_url":"https://codeload.github.com/joegasewicz/gorilla-controllers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248269567,"owners_count":21075783,"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":["controllers","gorilla","gorilla-mux","mvc","templates"],"created_at":"2024-10-30T22:56:00.724Z","updated_at":"2025-04-10T18:15:01.675Z","avatar_url":"https://github.com/joegasewicz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gorilla Controllers\nUse controllers with the Gorilla Mux library\n\n#### Why controllers?\nGorilla's mux library is a brilliant fully featured mux tool, Gorilla Controllers is a library that replaces the HandleFunc\nwith a `Controller` function \u0026 a `Templates` function. This way you only need to manage your data inside your controller, \nall your template setup logic is now handled by Gorilla Controllers.\n\n### Basic Usage\n\n\nCreate a controller\n```go\n// Create a controller - template data needs to be passed by value to `data *map[string]interface{}`\nfunc Home(w http.ResponseWriter, r *http.Request, data *map[string]interface{}) {\n    var templateData map[string]interface{} // Create a map to store your template data \n    templateData = make(map[string]interface{})\n    templateData[\"heading\"] = \"Create a new advert\"\n    *data = templateData // pass by value back to `data`\n}\n```\nLibrary Setup\n```go\nbaseTemplates := []string{\n    \"./templates/layout.html\",\n    \"./templates/sidebar.html\",\n    \"./templates/navbar.html\",\n    \"./templates/footer.html\",\n}\n\nr := mux.NewRouter()\ng := gorillacontrollers.New(r, baseTemplates, \"layout\") // \"layout\" is your base template\n\n\ng.Route(\"/\")\n    .Controller(Home) // Controller now replaces Gorilla's HandleFunc\n    .Methods(\"GET\", \"POST\")\n    .Templates(\"./templates/navbar.html\", \"./templates/home.html\") // If you do not call Templates() then you must call Init() instead\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoegasewicz%2Fgorilla-controllers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoegasewicz%2Fgorilla-controllers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoegasewicz%2Fgorilla-controllers/lists"}