Skip to content

feat(request): introduce typed Request object with lazy headers #101

Description

@ZhuchkaTriplesix

Context

  • Dependencies can request a request context dict built in src/params.rs (build_request_context).
  • Headers are copied entirely into a Python dict when any dependency wants request.

Problem

Raw dict API is weak for middleware, auth, and observability. Full header clone is expensive when deps only read one header.

Proposed change

  • Introduce oxyroute.Request with typed accessors: method, path, query_string, headers, client, cookies (minimal MVP).
  • Lazy header materialization or read-through wrapper; copy only on access.
  • Preserve compatibility: existing request["headers"] dict path or migration shim.

Files

  • oxyroute/ (new request.py or similar), src/params.rs, src/dispatch.rs
  • docs/dependencies.md, tests

Acceptance criteria

  • Dependency request injection works with new type (and legacy dict if kept).
  • Routes that do not touch headers avoid full header copy.
  • Docs show new API and migration notes.

Framework impact

Foundation for middleware, auth helpers, observability, and future typed utilities.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions