{"id":33188782,"url":"https://github.com/mynyml/simple_router","last_synced_at":"2025-11-16T07:00:55.081Z","repository":{"id":572310,"uuid":"204114","full_name":"mynyml/simple_router","owner":"mynyml","description":"Simple rack router","archived":false,"fork":false,"pushed_at":"2015-07-31T16:48:00.000Z","size":139,"stargazers_count":28,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-12T01:39:26.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"kelseyhightower/confd","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mynyml.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":"2009-05-18T18:43:36.000Z","updated_at":"2022-06-12T02:14:00.000Z","dependencies_parsed_at":"2022-07-05T00:31:22.616Z","dependency_job_id":null,"html_url":"https://github.com/mynyml/simple_router","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mynyml/simple_router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynyml%2Fsimple_router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynyml%2Fsimple_router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynyml%2Fsimple_router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynyml%2Fsimple_router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mynyml","download_url":"https://codeload.github.com/mynyml/simple_router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynyml%2Fsimple_router/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284672648,"owners_count":27044736,"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-11-16T02:00:05.974Z","response_time":65,"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":[],"created_at":"2025-11-16T05:00:36.676Z","updated_at":"2025-11-16T07:00:55.060Z","avatar_url":"https://github.com/mynyml.png","language":"Ruby","funding_links":[],"categories":["Routers","Middlewares"],"sub_categories":[],"readme":"\nSummary\n-------\nSmall and simple standalone router, meant for use with Rack applications.\n\nFeatures\n--------\n* Familiar Sinatra-like DSL for defining actions\n* Modular architecture (see ROUTING ENGINES section)\n* No magic\n* Low level / Highly flexible\n* Simple code\n\nExamples\n--------\n\n    class App\n      include SimpleRouter::DSL\n\n      get '/' do\n        'home'\n      end\n\n      get '/archives/:year/:month/:day' do |year, month, day|\n        Article.archived.find_by_date(year, month, day)\n      end\n\n      def call(env)\n        verb, path  = ENV['REQUEST_METHOD'], ENV['PATH_INFO']\n        route = self.class.routes.match(verb, path)\n        route.nil? ?\n          [404, {'Content-Type' =\u003e 'text/html'}, '404 page not found'] :\n          [200, {'Content-Type' =\u003e 'text/html'}, route.action.call(*route.values)]\n      end\n    end\n\nThe SimpleRouter::DSL mixin provides 5 class methods:\n\n    #get, #post, #put, #delete and #routes\n\nThe four verb methods allow you to define actions that will match a request for\nthe verb and route signature it defines.\n\nThe `#routes` method responds to `#match` and will return the first matching\nroute (in order they were defined). The route returned is a simple object; for\nthe second route in the example above, you get:\n\n    route.verb    #=\u003e :get\n    route.path    #=\u003e '/archives/:year/:month/:day'\n    route.action  #=\u003e lambda {|year, month, day| Article.archived.find_by_date(year, month, day) }\n    route.values  #=\u003e ['2008', '07', '01'] # after being matched with path '/archives/2008/07/01'\n\nSee examples/ directory for executable code examples.\n\nRouting Engines\n---------------\nBy design, the code is seperated in two main components:\n\n* DSL for defining routes/actions and retrieving requested action block.\n* Routing engine\n\nDifferent engines can be used by assigning them to the router:\n\n    SimpleRouter.engine = UltraFastEngine\n\nThis allows, for instance, a new faster engine to be used by an app without\nchanges in the top level DSL.\n\nEngines can also allow route definitions to include more (or less!) features.\nFor example, the built-in SimpleEngine allows route variables and extension\nhandling. Others could add variable conditions (`:id =\u003e Integer`), mime-type\nrestrictions, etc.\n\n### Engine Writers\n\nEngines only need to conform to a simple interface. See\nlib/simple_router/engines/simple_engine.rb for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmynyml%2Fsimple_router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmynyml%2Fsimple_router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmynyml%2Fsimple_router/lists"}