{"id":16786461,"url":"https://github.com/nklbdev/routy-csharp","last_synced_at":"2025-03-16T23:23:24.620Z","repository":{"id":40927683,"uuid":"112662829","full_name":"nklbdev/routy-csharp","owner":"nklbdev","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-10T06:37:39.000Z","size":6395,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T09:33:14.799Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/nklbdev.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-30T21:33:26.000Z","updated_at":"2023-09-10T06:37:34.000Z","dependencies_parsed_at":"2024-10-13T08:12:30.009Z","dependency_job_id":"f91382cb-5c81-4ca1-aea8-18f8564b86f4","html_url":"https://github.com/nklbdev/routy-csharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nklbdev%2Frouty-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nklbdev%2Frouty-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nklbdev%2Frouty-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nklbdev%2Frouty-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nklbdev","download_url":"https://codeload.github.com/nklbdev/routy-csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243945716,"owners_count":20372920,"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-13T08:12:18.430Z","updated_at":"2025-03-16T23:23:24.594Z","avatar_url":"https://github.com/nklbdev.png","language":"C#","readme":"# Routy is a routing library for building RESTful APIs in C#\n\n(it is still in the experimental stage)\n\n## Pros:\n\n* It does not use reflection to create controllers and set action parameters\n* It does not use string-based URL templates\n* Explicit specification of all type conversions\n* It is possible to use not only in RESTful APIs, but everywhere, where you need to choose strategies for processing URLs\n* It supports asynchronous handlers\n* It allows detection of errors in method signatures using compiler messages\n\nYou can build your routing in this way:\n\n```cs\npublic static void Main(string[] args)\n{\n    var cts = new CancellationTokenSource();\n    var ioc = new IoC();\n\n    new Server(Resource\u003cHttpListenerRequest, System.Action\u003cHttpListenerResponse\u003e\u003e\n            // Pass default controller factory to root resource\n            .Root(ioc.Resolve\u003cHomeController\u003e,\n                methods =\u003e methods\n                    // You can declare HTTP methods with many handlers\n                    // (Declare simple handlers first)\n                    .Method(\"get\", h =\u003e h\n                        // You can bind controller method\n                        .Query(q =\u003e q, cf =\u003e cf().Index)\n                        // or other controller method\n                        .Query(q =\u003e q, cf =\u003e ioc.Resolve\u003cHomeController\u003e().Index)\n                        // or async controller method\n                        .Query(q =\u003e q, cf =\u003e cf().IndexAsync)\n                        // or pass cancellation token to async method\n                        .Query(q =\u003e q.CancellationToken(), cf =\u003e cf().IndexAsync)\n                        // You also can bind another static method\n                        .Query(q =\u003e q, cf =\u003e Index)\n                        // or static asyncs\n                        .Query(q =\u003e q, cf =\u003e IndexAsync)\n                        .Query(q =\u003e q.CancellationToken(), cf =\u003e IndexAsync)\n                        // You can declare required query parameters\n                        .Query(q =\u003e q.Single(\"a\", int.Parse), cf =\u003e Index)\n                        // Or not required with default value\n                        .Query(q =\u003e q.Single(\"a\", int.Parse, 0), cf =\u003e Index)\n                        // Or array-parameters\n                        .Query(q =\u003e q.Array(\"a\", int.Parse), cf =\u003e Index)\n                        // You can extract any data from context by your own extractor\n                        // and declare it as parameter for your method\n                        .Query(q =\u003e q.Context(ct =\u003e ParseEntity(ct.InputStream), 4), cf =\u003e Index)\n                        // And of cource you can rearrange your\n                        // multiple parameters as you wish\n                        .Query(q =\u003e q\n                            .Single(\"a\", bool.Parse)\n                            .Single(\"b\", int.Parse)\n                            .Single(\"c\", int.Parse),\n                            cf =\u003e (a, b, c) =\u003e Index(b, a))),\n                // Declare nested resources\n                root =\u003e root\n                    // With concrete name\n                    // And with default controller factory from parent resource\n                    .Named(\"about\", methods =\u003e methods\n                        .Method(\"get\", h =\u003e h\n                            .Query(q =\u003e q, cf =\u003e cf().About)))\n                    // Or with other controller factory\n                    .Named(\"news\", ioc.Resolve\u003cNewsController\u003e,\n                        methods =\u003e methods\n                            .Method(\"get\", h =\u003e h\n                                .Query(q =\u003e q\n                                        .Single(\"page\", int.Parse, 0)\n                                        .Single(\"order\", bool.Parse, false),\n                                    cf =\u003e cf().Index)),\n                        news =\u003e news\n                            // Or use a value as a name\n                            // (with controller factory from parent resource or new)\n                            .Valued(int.Parse,\n                                methods =\u003e methods\n                                    .Method(\"get\", h =\u003e h\n                                        .Query(q =\u003e q, cf =\u003e cf().Get))))))\n        .Run(cts.Token).Wait();\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnklbdev%2Frouty-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnklbdev%2Frouty-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnklbdev%2Frouty-csharp/lists"}