package matryoshka-http-template:handlers

⌘K
Ctrl+K
or
/

    Overview

    Bridge is the boundary between odin-http and the matryoshka pipeline. This is the ONLY file in the template that imports both http and pipeline types. No http types appear in pipeline/ or runtime/.

    Thin odin-http route handler registration. Handlers contain no business logic — they delegate to the bridge.

    Index

    Types (2)
    Constants (0)

    This section is empty.

    Variables (0)

    This section is empty.

    Procedure Groups (0)

    This section is empty.

    Types

    Bridge ¶

    Bridge :: struct {
    	// inbox is the mailbox of the first pipeline stage (worker or translator_in).
    	inbox:   ^matryoshka.PolyNode,
    	builder: pipeline.Builder,
    	alloc:   runtime.Allocator,
    }
     

    Bridge converts an HTTP request to a pipeline Message, sends it through the pipeline, and converts the response Message back to an HTTP response.

    Ownership: - Bridge creates a per-request reply mailbox (closed after response is received). - Bridge creates the request Message and transfers ownership into the pipeline. - The terminal pipeline stage sends the response Message to reply_to. - Bridge receives the response, reads it, and frees the Message.

    Related Procedures With Parameters
    Related Procedures With Returns

    Handler_Data ¶

    Handler_Data :: struct {
    	bridge: ^Bridge,
    }
     

    Handler_Data bundles a bridge for use in a handler closure.

    Related Procedures With Parameters

    Constants

    This section is empty.

    Variables

    This section is empty.

    Procedures

    bridge_handle ¶

    bridge_handle :: proc(b: ^Bridge, req: ^http.Request, res: ^http.Response) {…}
     

    bridge_handle is the entry point called from an odin-http handler. It reads the request body, sends it through the pipeline, and writes the response. Blocks the calling thread until the pipeline stage replies.

    bridge_init ¶

    bridge_init :: proc(inbox: ^matryoshka.PolyNode, alloc: runtime.Allocator) -> Bridge {…}
     

    bridge_init creates a Bridge backed by the given allocator.

    make_handler ¶

    make_handler :: proc(data: ^Handler_Data) -> http.Handler {…}
     

    make_handler returns an odin-http Handler that delegates to the given bridge. The returned Handler contains a raw pointer to data — data must outlive the handler.

    register_handler ¶

    register_handler :: proc(router: ^http.Router, path: untyped string, b: ^Bridge) {…}
     

    register_handler registers a POST handler at the given path. The handler reads the request body, forwards it through the bridge, and writes the response.

    Usage: bridge := bridge_init(pipeline.worker.me.inbox, alloc) register_handler(&router, "/echo", &bridge)

    Procedure Groups

    This section is empty.

    Source Files