{"id":13366786,"url":"https://github.com/darccio/medeina","last_synced_at":"2025-03-12T18:31:27.062Z","repository":{"id":19524560,"uuid":"22771832","full_name":"darccio/medeina","owner":"darccio","description":"Go HTTP routing tree based on HttpRouter. Inspired by Roda and Cuba.","archived":true,"fork":false,"pushed_at":"2015-01-17T21:50:50.000Z","size":210,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-29T04:50:38.624Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/imdario/medeina","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/darccio.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":"2014-08-08T21:16:10.000Z","updated_at":"2023-01-28T21:14:59.000Z","dependencies_parsed_at":"2022-09-13T08:00:30.210Z","dependency_job_id":null,"html_url":"https://github.com/darccio/medeina","commit_stats":null,"previous_names":["darccio/medeina","imdario/medeina"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darccio%2Fmedeina","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darccio%2Fmedeina/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darccio%2Fmedeina/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darccio%2Fmedeina/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darccio","download_url":"https://codeload.github.com/darccio/medeina/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221309859,"owners_count":16795825,"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-07-30T00:01:31.890Z","updated_at":"2024-10-24T11:30:30.776Z","avatar_url":"https://github.com/darccio.png","language":"Go","funding_links":[],"categories":["Web Frameworks","XML"],"sub_categories":["Advanced Console UIs","路由"],"readme":"# Medeina [![Build Status][1]][2] [![GoDoc](https://godoc.org/github.com/imdario/medeina?status.svg)](https://godoc.org/github.com/imdario/medeina) [![Coverage Status](https://img.shields.io/coveralls/imdario/medeina.svg)](https://coveralls.io/r/imdario/medeina) [![docs examples](https://sourcegraph.com/api/repos/github.com/imdario/medeina/.badges/docs-examples.png)](https://sourcegraph.com/github.com/imdario/medeina) [![dependencies](https://sourcegraph.com/api/repos/github.com/imdario/medeina/.badges/dependencies.png)](https://sourcegraph.com/github.com/imdario/medeina)\n\n[1]: https://travis-ci.org/imdario/medeina.png\n[2]: https://travis-ci.org/imdario/medeina\n\n[Medeina](https://github.com/imdario/medeina) is a Go routing tree based on [HttpRouter](https://github.com/julienschmidt/httprouter) and inspired by Ruby's [Roda](http://roda.jeremyevans.net/) and [Cuba](http://cuba.is/). It allows to define the HTTP routes of your web application as a tree, operating on the current route at any point of the tree.\n\nAs stated in Roda's website, \"this allows you to have much DRYer code\". All the routes can have all the features of HttpRouter: named paramaters, catch-all parameters, etc.\n\nActually, Medeina inherits all the performance and flexibility you love in HttpRouter (great job, Julien!).\n\n## Status\n\nMedeina is fully functional and tested but it's still green and young. It may lack some useful functionality. If you use HttpRouter, give Medeina a try. All real world experience is welcome.\n\n## Install\n\n    go get github.com/imdario/medeina\n\n    // use in your .go code\n    import (\n        \"github.com/imdario/medeina\"\n    )\n\n## Usage\n\nCheck the [docs](https://godoc.org/github.com/imdario/medeina) and these examples:\n\n    // From Roda's site\n    r := medeina.NewMedeina()\n    r.GET(func() {\n        r.Is(\"\", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n            http.Redirect(w, r, \"/hello\", http.StatusFound)\n        })\n        r.On(\"hello\", func() {\n            r.Is(\"world\", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n                fmt.Fprintf(w, \"Hello world!\")\n            })\n            r.Is(\"\", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n                fmt.Fprintf(w, \"Hello!\")\n            })\n        })\n    })\n\n    log.Fatal(http.ListenAndServe(\":8080\", r))\n\n\nAnd this for a quick and dirty \"REST-like\" API (ignore the fact that I'm using a single method to handle everything):\n\n    endpoints := []string {\n        \"department\", \"employee\", \"project\"\n    }\n    r := medeina.NewMedeina()\n    r.GET(func() {\n        r.Is(\"\", Index)\n    })\n    for endpoint := range endpoints {\n        r.On(endpoint, func() {\n            r.GET(func() {\n                r.Is(\":id\", Model)\n            })\n            r.POST(func() {\n                r.Is(\"\", Model)\n            })\n            r.PUT(func() {\n                r.Is(\"\", Model)\n            })\n            r.DELETE(func() {\n                r.Is(\":id\", Model)\n            })\n        })\n    }\n\n    log.Fatal(http.ListenAndServe(\":8080\", r))\n\nOr it's \"shorter\" (YMMV) form:\n\n    endpoints := []string {\n        \"department\", \"employee\", \"project\"\n    }\n    r := medeina.NewMedeina()\n    r.Is(\"\", Index, medeina.GET)\n    for endpoint := range endpoints {\n        r.On(endpoint, func() {\n            r.Is(\"\", Model, medeina.POST, medeina.PUT)\n            r.Is(\":id\", Model, medeina.GET, medeina.DELETE)\n        })\n    }\n\n    log.Fatal(http.ListenAndServe(\":8080\", r))\n\nWhat does \"\" means? It matches the current path in your route. It's a way to easily match the scope itself as canonical URL.\n\n## Why HttpRouter?\n\nBecause it's the most fast and flexible Go HTTP router around the town and a good one to start. If you want Medeina to work with your preferred option, patches are welcome!\n\nIf you don't know [HttpRouter](https://github.com/julienschmidt/httprouter), please check it out. You won't regret it.\n\n## Why is it called Medeina?\n\nFrom [Wikipedia](https://en.wikipedia.org/wiki/Medeina):\n\n\u003e Medeina or Medeinė (derived from medis (tree) and medė (forest)), [...] is one of the main deities in the Lithuanian mythology, similar to Latvian Meža Māte. She is a ruler of forests, trees and animals. Her sacred animal is a hare.\n\nHey, we were talking about trees. It fits right! Also, this project can join my other ones, also called by names starting by 'm': [Mergo](https://github.com/imdario/mergo), [Minshu](https://github.com/imdario/minshu), [mqqsig192](https://github.com/imdario/mqqsig192), etc. Don't ask, it wasn't on purpose.\n\n## Contact me\n\nIf I can help you, you have an idea or you are using Medeina in your projects, don't hesitate to drop me a line (or a pull request): [@im_dario](https://twitter.com/im_dario)\n\n## About\n\nWritten by [Dario Castañé](http://dario.im).\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarccio%2Fmedeina","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarccio%2Fmedeina","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarccio%2Fmedeina/lists"}