{"id":23250562,"url":"https://github.com/hardenedelements/routable","last_synced_at":"2025-08-20T09:30:47.640Z","repository":{"id":46868062,"uuid":"98073208","full_name":"HardenedElements/routable","owner":"HardenedElements","description":"Platform agnostic request routing library for .NET","archived":false,"fork":false,"pushed_at":"2022-12-08T14:46:33.000Z","size":115,"stargazers_count":6,"open_issues_count":6,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-13T22:53:58.410Z","etag":null,"topics":["dotnet","dotnet-core","http","kestrel","routing","web-application-framework","web-service"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/Routable/","language":"C#","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/HardenedElements.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-23T03:55:36.000Z","updated_at":"2023-05-19T19:35:35.000Z","dependencies_parsed_at":"2023-01-25T14:15:25.266Z","dependency_job_id":null,"html_url":"https://github.com/HardenedElements/routable","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HardenedElements%2Froutable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HardenedElements%2Froutable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HardenedElements%2Froutable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HardenedElements%2Froutable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HardenedElements","download_url":"https://codeload.github.com/HardenedElements/routable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230408179,"owners_count":18220975,"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":["dotnet","dotnet-core","http","kestrel","routing","web-application-framework","web-service"],"created_at":"2024-12-19T09:12:47.903Z","updated_at":"2024-12-19T09:12:49.056Z","avatar_url":"https://github.com/HardenedElements.png","language":"C#","readme":"[![Build Status](https://travis-ci.org/HardenedElements/routable.svg?branch=master)](https://travis-ci.org/HardenedElements/routable) [![NuGet](https://img.shields.io/nuget/dt/Routable.svg)](https://preview.nuget.org/packages/Routable)\n\nRoutable\n=======\nRoutable is a simple, easy to use, request routing library. It is platform agnostic and designed to easily integrate with whatever platform you prefer. Support for Microsoft Kestrel is provided out the gate by ```Routable.Kestrel```, making routable a must-have for multi-platform web services and applications.\n\nRoutable is brand new; as such, it is missing a lot of **must-have** functionality. We hope to add this functionality as time permits, and if you see something you think we missed we would love it if you would file an issue (be detailed please; pull requests are welcome, but they may be modified significantly).\n\n## Three simple rules\nRoutable is governed by three simple rules. First, the base library is simple and needs to stay that way. It doesn't bother with things like views, complex content type negotiation or canned authentication schemes. Nope, routable is here to route your requests and give you the glorious opportunity to handle those requests. Second, the base library is platform agnostic and it doesn't quibble over the gory details of delivering complete and total commonality to everyone - no, instead, we route your requests and return you to your regularly scheduled platform. And finally, routable is extensible. We admit it, we use a lot of generics - but only because we love to see the way people work when tools get out of the way and let developers get in touch with their platform.\n\n## Libraries\nRoutable is a collection of libraries. First, you got your platform agnostic base library - that's ```Routable```. Then you have your simple *view* support - that's ```Routable.Views.Simple```. JSON support? Yeah, we integrate JSON.NET in ```Routable.Json```. And finally, you're going to need at least one platform integration to get started - we chose Kestrel because it's what we use the most; you can find that under ```Routable.Kestrel```. There are other platforms in the wind, but we haven't published those quite yet, they need some polishing up.\n\nLibrary | NuGet Download\n------- | --------------\nRoutable | [![NuGet](https://img.shields.io/nuget/v/Routable.svg)](https://preview.nuget.org/packages/Routable)\nRoutable.Kestrel | [![NuGet](https://img.shields.io/nuget/v/Routable.Kestrel.svg)](https://preview.nuget.org/packages/Routable.Kestrel)\nRoutable.Json | [![NuGet](https://img.shields.io/nuget/v/Routable.Json.svg)](https://preview.nuget.org/packages/Routable.Json)\nRoutable.Views.Simple | [![NuGet](https://img.shields.io/nuget/v/Routable.Views.Simple.svg)](https://preview.nuget.org/packages/Routable.Views.Simple)\n\n## Examples (targeting Kestrel)\nUsing a bit of creative license, we'll be using ```Routable.Kestrel``` as a companion to these examples, very little changes with other platforms (eg. change *kestrel* to *my favorite platform*).\n### Registration\n```csharp\npublic sealed class Startup\n{\n\tstatic void Main(string[] args) =\u003e new WebHostBuilder()\n\t\t.UseKestrel(options =\u003e options.Listen(IPAddress.Any, 8080))\n\t\t.Configure(builder =\u003e builder.UseRoutable(options =\u003e options\n\t\t\t.WithJsonSupport()\n\t\t\t.UseFileSystemViews(_ =\u003e _.AddSearchPath(\"views\").OnUnresolvedModelValue((expr, paths, model) =\u003e $\"[ERR! ({expr})]\"))\n\t\t\t.AddRouting(new MyRouting(options))\n\t\t\t.AddRouting(new KestrelRouting(options) {\n\t\t\t\t_ =\u003e _.Get(\"/meeseeks\").Do((ctx, req, resp) =\u003e resp.Write(\"Hi, I'm Mr. Meeseeks!\")),\n\t\t\t\t_ =\u003e _.Path(\"/grimey\").Do((ctx, req, resp) =\u003e resp.Write(\"I don't check methods, because I'm Homer Simpson!\"))\n\t\t\t})\n\t\t\t.OnError(new KestrelRouting(options) {\n\t\t\t\t_ =\u003e _.Do((context, request, response) =\u003e {\n\t\t\t\t\tresponse.Status = 500;\n\t\t\t\t\tresponse.Write($\"{context.Error?.GetType()?.FullName} ({context.Error?.Message}):\\n\\t{context.Error.StackTrace.Replace(\"\\n\", \"\\n\\t\")}\\n\");\n\t\t\t\t})\n\t\t\t})\n\t\t))\n\t\t.Build()\n\t\t.Run();\n}\n```\n### Routing in a Class\n```csharp\npublic sealed class MyRouting : KestrelRouting\n{\n\tpublic MyRouting(RoutableOptions\u003cKestrelRoutableContext, KestrelRoutableRequest, KestrelRoutableResponse\u003e options) : base(options)\n\t{\n\t\t// write a view using Routable.Views.Simple.\n\t\tAdd(_ =\u003e _.Get(\"/\").DoAsync(async (ctx, req, resp) =\u003e await resp.WriteViewAsync(\"index\", new {\n\t\t\tSomeModelField = \"Widget widget\"\n\t\t})));\n\n\t\tAdd(_ =\u003e _.Get(\"/test\").Do((ctx, req, resp) =\u003e resp.Write(\"Hello World!\")));\n\t\tAdd(_ =\u003e _.Post(\"/test\").Try(OnTestPost));\n\n\t\tAdd(_ =\u003e _.Get(\"/json\").Do((ctx, req, resp) =\u003e resp.Write(JObject.FromObject(new {\n\t\t\tField1 = 1,\n\t\t\tField2 = \"string?\"\n\t\t}))));\n\t}\n\n\tprivate bool OnTestPost(KestrelRoutableContext ctx, KestrelRoutableRequest req, KestrelRoutableResponse resp) {\n\t\tif(req.Form.TryGetValue(\"my-parameter\", out var value) == true) {\n\t\t\tresp.Write($\"Value: {value.FirstOrDefault() ?? \"\u003cnull\u003e\"}\");\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardenedelements%2Froutable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardenedelements%2Froutable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardenedelements%2Froutable/lists"}