{"id":18336056,"url":"https://github.com/maxim5/routekit","last_synced_at":"2025-04-06T04:34:52.536Z","repository":{"id":83950876,"uuid":"383914692","full_name":"maxim5/routekit","owner":"maxim5","description":"Super-fast and lightweight Java URL router.","archived":false,"fork":false,"pushed_at":"2023-04-06T21:35:15.000Z","size":142,"stargazers_count":10,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T17:11:56.532Z","etag":null,"topics":["high-performance","java","router","routing","url","web"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxim5.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":"2021-07-07T20:15:01.000Z","updated_at":"2025-01-07T07:57:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e9d374d-215d-4ae4-9eba-21784e21b4bf","html_url":"https://github.com/maxim5/routekit","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxim5%2Froutekit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxim5%2Froutekit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxim5%2Froutekit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxim5%2Froutekit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxim5","download_url":"https://codeload.github.com/maxim5/routekit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247435043,"owners_count":20938530,"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":["high-performance","java","router","routing","url","web"],"created_at":"2024-11-05T20:05:51.001Z","updated_at":"2025-04-06T04:34:52.526Z","avatar_url":"https://github.com/maxim5.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Java Ro*u*teKit\n---------------\n\nSuper-fast and lightweight Java URL router.\n\n### Features\n\n- **Fast**: highly efficient routing algorithm using hashtable index, prefix trie and finite state machine. No regexp matching.\n- **GC friendly**: minimal number of allocations during routing. No unnecessary copying and `String` and `char[]` waste.\n- **Small**: whole library is one 30kb jar.\n- **Scalable**: can handle thousands of rules without overhead.\n- **Simple**: supports string variables and wildcards.\n- **Lightweight**. No dependencies on other libraries. None. Zero.\n- **Adaptable**: API does not require or force any web framework or library. Works with any `String` or `char[]` input.\n- **Compatible**: Netty.\n- **Extensible**: supports options and extension points for new rule syntax, tokens or customized matching.\n\n### Example usage\n\n```java\n// The setup: map the urls to a handler (can be any class).\nRouter\u003cT\u003e router = new RouterSetup\u003cT\u003e()\n    .add(\"/\", ...)\n    .add(\"/foo\", ...)\n    .add(\"/bar\", ...)\n    .build();\n```\n\nFor example, if you have a `Handler` hierarchy, implemented by per-page classes (`HomeHandler`, `UserHandler`, etc),\nit might look like this:\n\n```java\nRouter\u003cHandler\u003e router = new RouterSetup\u003cHandler\u003e()\n    .add(\"/\", new HomeHandler())\n    .add(\"/user\", new ListUsersHandler())\n    .add(\"/user/{id}\", new UserHandler())\n    .add(\"/post\", new ListBlogPostsHandler())\n    .add(\"/post/{id}\", new BlogPostHandler())\n    .add(\"/post/{id}/{slug}\", new BlogPostHandler())\n        ...\n    .build();\n```\n\nURL navigation is as follows:\n\n```java\nMatch\u003cHandler\u003e match = router.routeOrNull(url);\nif (match == null)\n    throw new NotFoundException();\nreturn match.handler().accept(match.variables());\n```\n\nNote the handler can use the variables map, like `id` -\u003e `123`.\n\n### Performance\n\nBenchmark results for a small/medium size setup show that routing static URL (without variables) throughput \ncan reach \u003cb\u003e55m ops/sec\u003c/b\u003e, one variable URL - \u003cb\u003e10m ops/sec\u003c/b\u003e, two variables URL - \u003cb\u003e6m ops/sec\u003c/b\u003e.\n\u003cbr\u003e\nEnvironment: AMD Ryzen 5 4600H, 3.00 GHz, \u003cb\u003esingle-threaded\u003c/b\u003e.\n\n\u003ca href='/src/test/java/io/routekit/jmh'\u003eJMH benchmark\u003c/a\u003e output below:\n\n```\nBenchmark                                 (iterations)   Mode   Samples        Score  Score error    Units\ni.r.j.RouterBenchmark.route_home                  1000  thrpt        10    55373,952     1356,069    ops/s\ni.r.j.RouterBenchmark.route_post                  1000  thrpt        10    10935,147      190,314    ops/s\ni.r.j.RouterBenchmark.route_post_slug             1000  thrpt        10     6207,792       59,925    ops/s\ni.r.j.RouterBenchmark.route_user                  1000  thrpt        10     9918,927      290,196    ops/s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxim5%2Froutekit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxim5%2Froutekit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxim5%2Froutekit/lists"}