The core functionality was inspired by Jonathan Amsterdam's alternative ServeMux implementation draft. For full discussion see the proposal here.
Mr. Amsterdam's draft contains unnecessary complexity for detecting route intersections, because it includes HTTP method differentiation inside the routing tree and does not anchor to the end of the request path without an explicit [$]
segment.
In this implementation, all request paths are anchored to the end, unless ending with [...]
, and the routing by method is set aside into a separate MethodMux
handler. Therefore, the route intersections are always correctly caught at initialization, when the routing tree grows. This should also lead to slightly faster performance when working with live application routing trees.
Domain logic adaptors come in three general flavors:
- UnaryFunc: func(context, inputStruct) (outputStruct, error)
- NullaryFunc: func(context) (outputStruct, error)
- VoidFunc: func(context, inputStruct) error
Each input requires implementation of adapt.Validatable
for safety. Validation errors are decorated with the correct http.StatusUnprocessableEntity
status code.