AshTypescript.TypedController.RequestHandler (ash_typescript v0.18.1)

Copy Markdown View Source

Handles request lifecycle for typed controller routes.

Normalizes params (camelCase → snake_case), extracts and casts declared arguments using Ash.Type.cast_input/3, validates required arguments, then dispatches to the route handler (inline fn/2 or module implementing AshTypescript.TypedController.Route).

Only declared arguments are passed to the handler — undeclared params are dropped. If any required argument is missing or any cast fails, a 422 error response is returned without invoking the handler.

Error Shape

Errors use the same shape as RPC errors (AshTypescript.Rpc.Error), so a client can handle both with one code path:

%{
  type: "required",
  message: "is required",
  short_message: "Required field",
  vars: %{field: "code"},
  fields: ["code"],
  path: []
}

message keeps its %{var} placeholders and vars carries the values, as in RPC — interpolation is left to the client. All keys are run through the configured output_field_formatter before being sent.

Summary

Functions

Handles a route request by extracting, casting, and validating arguments, then dispatching to the configured handler.

Functions

handle(conn, source_module, route_name, params)

Handles a route request by extracting, casting, and validating arguments, then dispatching to the configured handler.