Overview
Neuro.Networking.HttpRouter supports two complementary styles:
- Manual endpoint registration with
RegisterGet,RegisterPost,RegisterPut,RegisterPatch,RegisterDelete, andRegisterOptions - Attribute-based controllers with per-request controller instances, binding, validation, staged middleware, and automatic JSON responses
The main package documented here is
Neuro.Networking.HttpRouter. Controller-based APIs also use types from Neuro.Networking.HttpRouter.Core, and OpenAPI generation uses the companion Neuro.Networking.HttpRouter.OpenApi assembly.Install the package
Minimal setup
Create aControllerEndpointRouter, register it with your HTTP server, and then either scan an assembly or register one controller directly.
/users becomes available under /api/users.
Current feature surface
The current router surface includes:- Per-request controller instances and constructor injection through
Router.ServiceProvider - Transport validation on bound parameters and body models
- A staged middleware pipeline from
InfrastructurethroughPostHandler - Router-level authentication scheme registration through
UseAuthenticationScheme(...) - Configurable JSON field naming through the router’s
IParameterNameCodec - OpenAPI document generation from the registered route tree
A first mental model
When a request hits the router:- Matches the HTTP method and path
- Runs any middleware registered for that route and stage
- Creates a controller instance for the request
- Binds route, query, and body values to method parameters and validates them
- Calls the controller action
- Serializes the returned object to JSON unless the action is raw
First example
GET request to /api/users/42 returns JSON based on the UserResponse object.
A good default order
Register middleware before callingRegisterControllers(...) if you want it to run in front of your controllers.
Router-level authentication helpers
The router can also advertise authentication schemes for the endpoints it serves.UseAuthenticationScheme(...) with a custom HttpAuthenticationScheme when the built-in account, legal-signature, or anonymous schemes are not enough.
OpenAPI document generation
TheNeuro.Networking.HttpRouter.OpenApi companion assembly can generate an OpenAPI document from the routes registered on a ControllerEndpointRouter.
The generator returns the typed OpenApiDocument model from Neuro.Content.OpenApi, which also provides the JSON content codec used when the document is returned over HTTP.
Parklet exposes this as a normal endpoint:
3.0.3 document. It infers paths, route parameters, query parameters, request bodies, response schemas, and security metadata from registered controllers and manual endpoints. It also uses the active IParameterNameCodec, so a router configured with SnakeCaseParameterNameCodec produces snake-case JSON schema fields.
Use [Summary], [Description], and [Tag] from Neuro.Networking.HttpRouter.OpenApi to improve operation text and grouping in generated docs.