The HTTP services post in this series gave routing a section called "The Weak Spot", showed four lines of the Go 1.22 mux, and moved on to chi, gorilla and gin. This post covers what that section left out: the pattern language set against attribute routing, and the things ASP.NET Core does around its router that Go's mux does not attempt. It then fills most of that list with a small library I wrote for the purpose, mapget . Every snippet and every response below was run on go1.27.3.
What you had in C
[ ApiController ] [ Route ( "orders" ) ] public class OrdersController : ControllerBase { [ HttpGet ( "{id:int}" ) ] public ActionResult < Order > Get ( int id , [ FromQuery ] string [ ] expand ) { . . . }
[ HttpPost ] public ActionResult < Order > Create ( NewOrder body ) { . . . return CreatedAtAction ( nameof ( Get ) , new { id = order . Id } , order ) ; } }
Enter fullscreen mode
Exit fullscreen mode
That controller uses six separate features. The route template is matched.…