{"id":26059982,"url":"https://github.com/vuchkov/golang-rest-api","last_synced_at":"2026-05-20T07:12:25.248Z","repository":{"id":278759899,"uuid":"936685405","full_name":"vuchkov/golang-rest-api","owner":"vuchkov","description":"Simple Go (Golang) REST API (JSON)","archived":false,"fork":false,"pushed_at":"2025-02-21T14:12:40.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T13:48:46.964Z","etag":null,"topics":["api","go","golang","json","rest-api","restful"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vuchkov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-02-21T14:06:57.000Z","updated_at":"2025-02-21T14:14:38.000Z","dependencies_parsed_at":"2025-02-21T15:34:32.675Z","dependency_job_id":null,"html_url":"https://github.com/vuchkov/golang-rest-api","commit_stats":null,"previous_names":["vuchkov/golang-rest-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vuchkov/golang-rest-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuchkov%2Fgolang-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuchkov%2Fgolang-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuchkov%2Fgolang-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuchkov%2Fgolang-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vuchkov","download_url":"https://codeload.github.com/vuchkov/golang-rest-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuchkov%2Fgolang-rest-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267899153,"owners_count":24162991,"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-07-30T02:00:09.044Z","response_time":70,"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":["api","go","golang","json","rest-api","restful"],"created_at":"2025-03-08T13:48:50.281Z","updated_at":"2026-05-20T07:12:20.204Z","avatar_url":"https://github.com/vuchkov.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Go (Golang) REST API (JSON)\n\nThe task requires implementing a GET API endpoint in Go using the `gorilla/mux` router. \nThe endpoint `/users` should return user data from a mocked database and support filtering by the `name` query parameter.\n\n## Installation \u0026 Usage\n\n1. Setup a Go project:\n```\ngo mod init myapi\ngo get github.com/gorilla/mux\n\n```\n\n2. Create `main.go`:\n```\npackage main\n\nimport (\n    \"encoding/json\"\n    \"net/http\"\n    \"github.com/gorilla/mux\"\n    \"github.com/codility/rest_api_go/database\"\n)\n\nfunc getUsersHandler(w http.ResponseWriter, r *http.Request) {\n    users := database.GetUsers()\n    queryName := r.URL.Query().Get(\"name\")\n\n    var filteredUsers []database.User\n    for _, user := range users {\n        if queryName == \"\" || user.Name == queryName {\n            filteredUsers = append(filteredUsers, user)\n        }\n    }\n\n    w.Header().Set(\"Content-Type\", \"application/json\")\n    w.WriteHeader(http.StatusOK)\n    json.NewEncoder(w).Encode(filteredUsers)\n}\n\nfunc main() {\n    r := mux.NewRouter()\n    r.HandleFunc(\"/users\", getUsersHandler).Methods(\"GET\")\n\n    http.ListenAndServe(\":8080\", r)\n}\n```\n\n3. Result:\n\n- `GET /users` → Returns all users.\n- `GET /users?name=John` → Returns only users with `name=\"John\"`.\n- If no user matches the filter, returns an empty array `[]`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvuchkov%2Fgolang-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvuchkov%2Fgolang-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvuchkov%2Fgolang-rest-api/lists"}