{"id":16848126,"url":"https://github.com/araddon/m2go","last_synced_at":"2025-04-11T06:34:54.869Z","repository":{"id":1929192,"uuid":"2857733","full_name":"araddon/m2go","owner":"araddon","description":"Mongrel2 Handler for Go","archived":false,"fork":false,"pushed_at":"2012-05-07T02:02:37.000Z","size":112,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T17:11:20.045Z","etag":null,"topics":[],"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/araddon.png","metadata":{"files":{"readme":"README.rst","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}},"created_at":"2011-11-26T21:11:48.000Z","updated_at":"2023-04-07T01:55:38.000Z","dependencies_parsed_at":"2022-09-09T05:21:19.986Z","dependency_job_id":null,"html_url":"https://github.com/araddon/m2go","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/araddon%2Fm2go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/araddon%2Fm2go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/araddon%2Fm2go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/araddon%2Fm2go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/araddon","download_url":"https://codeload.github.com/araddon/m2go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239562190,"owners_count":19659604,"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":[],"created_at":"2024-10-13T13:10:10.437Z","updated_at":"2025-02-18T22:31:22.730Z","avatar_url":"https://github.com/araddon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"m2go, a `Mongrel2 http server \u003chttp://mongrel2.org\u003e`_ for go.   \n\nIncludes adapter to run `Pat.go \u003cgithub.com/bmizerany/pat\u003e`_ \n\n\nUsage\n===================\n\nExample App::\n\n\timport (\n\t\t\"github.com/araddon/m2go\"\n\t\t\"github.com/bmizerany/pat\"\n\t\t\"io\"\n\t\t\"log\"\n\t\t\"net/http\"\n\t)\n\n\tfunc main() {\n\t\tlog.SetFlags(log.Ltime | log.Lshortfile)\n\t\tm := pat.New()\n\t\tm.Get(\"/hello/:name\", http.HandlerFunc(hello))\n\t\tm.Get(\"/stream\", http.HandlerFunc(stream))\n\t\tm2go.ListenAndServe(\"tcp://127.0.0.1:9055|tcp://127.0.0.1:9056|d9eae9a0-6bad-11e1-9cc3-5254004a61b5\", m)\n\t}\n\n\tfunc hello(w http.ResponseWriter, r *http.Request) {\n\t\tname := r.URL.Query().Get(\":name\")\n\t\tio.WriteString(w, \"Hello, \"+name)\n\t}\n\n\t// this will serve as a Streaming API, continuing to push out updates\n\t// to connected client\n\tfunc stream(w http.ResponseWriter, r *http.Request) {\n\t\t// this line:  is the key to make it streaming.\n\t\tr.Header.Set(\"Transfer-Encoding\", \"chunked\")\n\t\tr.Header.Set(\"Content-Type\", \"application/json\")\n\t\tio.WriteString(w, \"some content\")\n\t\t\n\t\t// lets simulate a zeromq type connection that recieves messages periocically\n\t\t//  and pushes to client\n\t\ttimer := time.NewTicker(time.Second * 1)\n\n\t\tgo func() {\n\t\t\tfor _ = range timer.C {\n\t\t\t\tio.WriteString(w, `{\"msg\":\"still alive\",\"status\":200}`)\n\t\t\t}\n\t\t}()\n\t}","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faraddon%2Fm2go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faraddon%2Fm2go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faraddon%2Fm2go/lists"}