Endpoint Routing
Endpoint Routing
Saturn from version 0.15 supports ASP.NET Endpoint Routing additionally to custom routing implementation provided by Giraffe. The main difference between old routing and new one is that Endpoint Routing assumes total separation of routing from behavior - it works by statically defining list of all possible routes on startup of application. This impacts design of some of our Saturn abstractions, and means new routing is not 100% compatible with old one. On the bright side, theoretically, Endpoint Routing should provide noticeable performance boost, and in the future it will allow for better ecosystem integration.
Currently endpoint routing API is treated as an experimental API - it's subject to changes.
To use Endpoint Routing you need to open Saturn.Endpoint namespace - this will override known router and controller Computation Expressions with their Endpoint Routing versions. In application CE instead of using use_router operation you should use use_endpoint_router operation. For many simple applications this may be enough to get things working - we've been trying to keep API as compatible as possible.
However there are differences:
- With Endpoint Routing routerandcontrollercomputation expressions are not transformed toHttpHandlerbut rather toEndpoint list. This has a huge impact on composability of those abstractions - you can't do things likemyHttpHandler >=> router { ... }any more. Such code should be replaced withplug/pipe_throughfunctionality in bothrouterandcontroller.Endpoint listcan basically be used in 2 places - inforwardoperation inrouteranduse_endpoint_routerinapplication.
- Lack of subroutefin Giraffe-EndpointRouting - because EndpointRouting needs to have all possible route templates at the application startup it's really hard to emulate some of previous Giraffe's routing composibility capabilities. From Saturn point of view this created 2 major changes:- there's no forwardfinrouterCE anymore - it should be replaced with set ofgetf/postf/putf ...operations in child router.
- subControllerin- controllerCE doesn't work well in Endpoint Routing - you can use as subcontrollers only old, HttpHandler based controllers (even if you parent controller is Endpoint Routing controller). In- Saturn.Endpointwe provide additonal- subcontrollerCE - it's an alias to old- controllerCE
 
- there's no 
- Lack of case_insensitiveinrouterandcontroller- with Endpoint Routing all routes are case insensitive by default and there's no easy way to change it
- Lack of not_found_handlerinrouterandcontroller- as Endpoint Routing creates global table of routing having scoped not-found handlers is really tricky. Use built-in ways of handle 404 in ASP.NET (such asUseDeveloperExceptionPage)
- Unlike Giraffe routing, Endpoint Routing doesn't ensure order of routing checks - this shouldn't be a problem in most cases, but I can imagine some edge cases in which this would matter.
In general, to reiterate - Endpoint Routing API in Giraffe/Saturn is still experimental. However, it probably is a future of Giraffe/Saturn so, if possible, please check if your applications can move to the Endpoint Routing API, and try it out. It's important for everyone involved to get feedback on this new routing engine.