Wymcp.Plugs.Pipeline (Wymcp v0.1.1)

View Source

The POST plug chain: every check and stage a POST passes through, in the one order that makes each stage's precondition true.

Wymcp.Plugs.OriginCheck        # wire check 1 — before anything is parsed
parse_body                     # Plug.Parsers, JSON
Wymcp.Plugs.Classify           # message kind
Wymcp.Plugs.Auth               # wire check 2
Wymcp.Plugs.SingletonHeaders   # wire check 3
Wymcp.Plugs.Era                # era classification
Wymcp.Plugs.ProtocolFields     # modern-lane enforcement
Wymcp.Plugs.Session            # legacy-lane session resolution
Wymcp.Plugs.Validate           # MCP schema
Wymcp.Plugs.Dispatch           # method → its answering module

Why that order. The origin check runs first because nothing has validated Origin when it runs — Wymcp.Router's wire-check invariant. Parsing and classification sit between it and the other two checks so their rejections can carry the body's id and know the message kind. Era classification runs after the singleton-header check, which guarantees at most one Mcp-Session-Id for it to read. Validation runs last before dispatch, so the wire and session checks answer first.

Body parsing is an inline function rather than a plug so that a malformed body answers in wymcp's own dialect: Plug.Parsers.ParseError is rescued and answered HTTP 400 plus -32700 with data.reason, instead of propagating as Plug's own error.

GET and DELETE do not run this pipeline. Wymcp.Router runs the same three wire checks in those route bodies, in the same order, speaking the plain-JSON dialect.

Summary

Functions

Callback implementation for Plug.call/2.

Callback implementation for Plug.init/1.

Functions

call(conn, opts)

Callback implementation for Plug.call/2.

init(opts)

Callback implementation for Plug.init/1.