Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.neuro-tech.io/llms.txt

Use this file to discover all available pages before exploring further.

Advanced Patterns

Take full control with raw requests, manual endpoints, and parameter-name codecs.

When the high-level API is not enough

Most controller methods should stay in the normal attribute-based model. Reach for the advanced tools when you need:
  • Manual control over how the request body is read
  • Manual control over the exact response shape
  • Low-level endpoint registration without controllers
  • A custom JSON naming convention

Raw requests

[RawRequest] disables automatic binding and response serialization for a controller method. When you use it:
  • The method must return Task
  • The method must take exactly two parameters
  • The second parameter must be HttpResponse
  • For GET and DELETE, the first parameter must be ExtendedHttpRequest
  • For POST, PUT, and PATCH, the first parameter must be HttpBodyRequest
[Controller]
[Route("/orders")]
public sealed class OrdersController : ControllerBase
{
    [RawRequest]
    [HttpGet("/[orderId]")]
    public async Task Get(ExtendedHttpRequest Request, HttpResponse Response)
    {
        await Response.Return(new OrderStatusApiResponse
        {
            OrderId = Request.RouteParameters.Required("orderId"),
            Status = "queued"
        });
    }
}
In raw mode, you are responsible for reading all values and sending the response yourself.

Manual endpoint registration

The router also supports a low-level style without controllers:
EndpointRouter Router = new EndpointRouter("/api", true);

Router.RegisterGet("/users/[userId]", (ExtendedHttpRequest Request, HttpResponse Response) =>
{
    string UserId = Request.RouteParameters.Required("userId");
    return Response.Return(new UserApiResponse
    {
        UserId = UserId,
        DisplayName = "Ada"
    });
});
This style is useful when you want a lightweight route table or need to build endpoints dynamically.

Parameter-name codecs

The router uses IParameterNameCodec to map CLR member names to JSON field names. Built-in codecs:
  • CamelCaseParameterNameCodec
  • SnakeCaseParameterNameCodec
  • TransparentParameterNameCodec
To change the default codec before controller registration:
Types.RegisterDefaultImplementation(typeof(IParameterNameCodec), typeof(SnakeCaseParameterNameCodec));

EndpointRouter Router = new EndpointRouter("/api", true);
Router.RegisterControllers(typeof(UsersController).Assembly);
The same codec is used for both request body decoding and response encoding.

A simple rule of thumb

Stay with normal attributed methods until you have a concrete reason not to. Use raw requests when:
  • The body shape is unusual
  • You need direct access to parser output
  • You want full control over the response lifecycle
Use manual endpoint registration when:
  • Controllers would add ceremony without helping
  • Routes are generated or highly dynamic
  • You want to build a focused low-level module