{"id":13508001,"url":"https://github.com/sugar-framework/elixir-http-router","last_synced_at":"2026-02-21T17:34:06.656Z","repository":{"id":26445034,"uuid":"29895978","full_name":"sugar-framework/elixir-http-router","owner":"sugar-framework","description":"HTTP Router with various macros to assist in developing your application and organizing your code","archived":false,"fork":false,"pushed_at":"2025-01-18T22:38:17.000Z","size":33,"stargazers_count":14,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-01T08:14:20.404Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/http_router","language":"Elixir","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/sugar-framework.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":"2015-01-27T03:41:38.000Z","updated_at":"2025-01-18T22:38:20.000Z","dependencies_parsed_at":"2025-03-30T09:33:24.433Z","dependency_job_id":"68a00108-4228-4c79-b88e-41f9a4a2e9db","html_url":"https://github.com/sugar-framework/elixir-http-router","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sugar-framework/elixir-http-router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sugar-framework%2Felixir-http-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sugar-framework%2Felixir-http-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sugar-framework%2Felixir-http-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sugar-framework%2Felixir-http-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sugar-framework","download_url":"https://codeload.github.com/sugar-framework/elixir-http-router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sugar-framework%2Felixir-http-router/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29688272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T15:51:39.154Z","status":"ssl_error","status_checked_at":"2026-02-21T15:49:03.425Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-08-01T02:00:45.255Z","updated_at":"2026-02-21T17:34:06.613Z","avatar_url":"https://github.com/sugar-framework.png","language":"Elixir","readme":"# HttpRouter\n[![Build Status](https://img.shields.io/travis/sugar-framework/elixir-http-router.svg?style=flat)](https://travis-ci.org/sugar-framework/elixir-http-router)\n[![Coverage Status](https://img.shields.io/coveralls/sugar-framework/elixir-http-router.svg?style=flat)](https://coveralls.io/r/sugar-framework/elixir-http-router)\n[![Hex.pm Version](http://img.shields.io/hexpm/v/http_router.svg?style=flat)](https://hex.pm/packages/http_router)\n[![Inline docs](http://inch-ci.org/github/sugar-framework/elixir-http-router.svg?branch=master)](http://inch-ci.org/github/sugar-framework/elixir-http-router)\n\n\u003e HTTP Router with various macros to assist in\n\u003e developing your application and organizing\n\u003e your code\n\n## Installation\n\nAdd the following line to your dependency list\nin your `mix.exs` file, and run `mix deps.get`:\n\n```elixir\n{:http_router, \"~\u003e 0.0.1\"}\n```\n\nAlso, be sure to add `:http_router` to the list\nof applications on which your web application\ndepends (the default looks something like\n`applications: [:logger]`) in your `mix.exs`\nfile.\n\nBe sure to have [Plug][plug] in your dependency\nlist as well as this is essentially a\nreimagination of the `Plug.Router` module, and\nas such, it still make use of a large portion\nof the Plug library.\n\n## Usage\n\nTo get the benefits that this package has to\noffer, it is necessary to use the `HttpRouter`\nmodule in one of your modules that you wish to\nact as the router for your web application.\nSimilar to `Plug.Router`, we can start with a\nsimple module:\n\n```elixir\ndefmodule MyRouter do\n  use HttpRouter\nend\n```\n\nThat was easy, huh? Now, this module still needs a\nfew calls to the below macros, but this depends on\nhow your application needs to be structured.\n\n### The Macros\n\nCheck out this convoluted example:\n\n```elixir\ndefmodule MyRouter do\n  use HttpRouter\n\n  # Define one of the versions of the API\n  # with a simple version number \"1\"\n  # or following semver \"1.0.0\"\n  # or date of release \"2014-09-06\"\n  version \"1\" do\n    # Define your routes here\n    get  \"/\",               Handlers.V1.Pages, :index\n    get  \"/pages\",          Handlers.V1.Pages, :create\n    post \"/pages\",          Handlers.V1.Pages, :create\n    put  \"/pages/:page_id\" when id == 1,\n                            Handlers.V1.Pages, :update_only_one\n    get  \"/pages/:page_id\", Handlers.V1.Pages, :show\n\n    # Auto-create a full set of routes for resources\n    #\n    resource :users,        Handlers.V1.User, arg: :user_id\n    #\n    # Generates:\n    #\n    # get     \"/users\",           Handlers.V1.User, :index\n    # post    \"/users\",           Handlers.V1.User, :create\n    # get     \"/users/:user_id\",  Handlers.V1.User, :show\n    # put     \"/users/:user_id\",  Handlers.V1.User, :update\n    # patch   \"/users/:user_id\",  Handlers.V1.User, :patch\n    # delete  \"/users/:user_id\",  Handlers.V1.User, :delete\n    #\n    # options \"/users\",           \"HEAD,GET,POST\"\n    # options \"/users/:_user_id\", \"HEAD,GET,PUT,PATCH,DELETE\"\n  end\n\n  # An updated version of the AP\n  version \"2\" do\n    get  \"/\",               Handlers.V2.Pages,  :index\n    post \"/pages\",          Handlers.V2.Pages,  :create\n    get  \"/pages/:page_id\", Handlers.V2.Pages,  :show\n    put  \"/pages/:page_id\", Handlers.V2.Pages,  :update\n\n    raw :trace, \"/trace\",   Handlers.V2.Tracer, :trace\n\n    resource :users,        Handlers.V2.User\n    resource :groups,       Handlers.V2.Group\n  end\nend\n```\n\n`get/3`, `post/3`, `put/3`, `patch/3`, `delete/3`,\n`options/2`, and `any/3` are already built-in as\ndescribed. `resource` exists but will need\nmodifications to create everything as noted.\n\n`raw/4` allows for using custom HTTP methods, allowing\nyour application to be HTTP spec compliant.\n\n`version/2` will need to be created outright. Will\nallow requests to contained endpoints when version\nexists in either `Accepts` header or URL (which ever\nis defined in app config).\n\nExtra routes will need to be added for `*.json`,\n`*.xml`, etc. requests for optionally specifying\ndesired content type without the use of the\n`Accepts` header. These should match\nparsing/rendering abilities of your application.\n\n## Configuration\n\nTBD.\n\n## License\n\nHttpRouter is released under the MIT License.\n\nSee [LICENSE](license) for details.\n\n[plug]: https://github.com/elixir-lang/plug\n[license]: https://github.com/sugar-framework/elixir-http-router/blob/master/LICENSE\n","funding_links":[],"categories":["Framework Components"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsugar-framework%2Felixir-http-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsugar-framework%2Felixir-http-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsugar-framework%2Felixir-http-router/lists"}