cratestack_axum/lib.rs
1//! Axum-bound runtime helpers for cratestack.
2//!
3//! The crate is organized into themed modules; see each for details:
4//!
5//! - [`codec`]: codec-bound encode/decode and the [`CodecSet`] pairing.
6//! - [`transport`]: the [`HttpTransport`] trait and the
7//! `encode_transport_*` response family.
8//! - [`headers`]: request-header helpers (ETag, traceparent, client IP).
9//! - [`query`]: URL query parsing and the filter expression grammar.
10//! - [`rpc`]: the RPC binding (`POST /rpc/{op_id}` and
11//! `POST /rpc/batch`).
12//! - [`idempotency`]: idempotency-key middleware and storage trait.
13//! - `middleware_error` (private): the shared, codec-negotiated error
14//! envelope both middleware layers emit (cratestack#846).
15//! - [`ratelimit`]: token-bucket rate-limit middleware and storage trait.
16//! - [`schema_fingerprint`]: warn-only client/server schema drift
17//! detection via the `x-cratestack-schema-sha` header.
18//! - [`trusted_proxy`]: the [`TrustedProxyConfig`] allowlist/hop-count/
19//! [`ForwardedHeader`] type consumers apply as an `Extension` to make
20//! `Forwarded`/`X-Forwarded-For` trust explicit (#415).
21
22pub use axum;
23
24pub mod codec;
25pub mod headers;
26pub mod idempotency;
27mod middleware_error;
28pub mod projection;
29pub mod query;
30pub mod ratelimit;
31pub mod rpc;
32pub mod schema_fingerprint;
33pub mod transport;
34pub mod trusted_proxy;
35
36// -----------------------------------------------------------------------------
37// Crate-root re-exports — every item the `cratestack-macros` crate references
38// from `cratestack_axum::*` must remain importable from the crate root. The
39// list below is explicit (not `pub use module::*;`) so the public surface is
40// greppable from this file.
41// -----------------------------------------------------------------------------
42
43pub use codec::{
44 CodecSet, decode_codec_request, encode_codec_response, encode_codec_result,
45 encode_codec_result_with_status, validate_codec_request_headers,
46 validate_codec_response_headers,
47};
48
49pub use transport::{
50 CBOR_SEQUENCE_CONTENT_TYPE, HttpTransport, decode_transport_request_for,
51 encode_transport_result, encode_transport_result_with_status,
52 encode_transport_result_with_status_for, encode_transport_sequence_result,
53 encode_transport_sequence_result_with_status, encode_transport_sequence_result_with_status_for,
54 encode_transport_stream_result_with_status_for, validate_transport_request_headers,
55 validate_transport_request_headers_for, validate_transport_response_headers,
56 validate_transport_response_headers_for,
57};
58
59pub use headers::{
60 ClientIpContext, enrich_context_from_headers, parse_client_ip, parse_if_match_version,
61 parse_traceparent, set_version_etag,
62};
63
64pub use projection::ProjectedValue;
65
66pub use query::{
67 QueryExpr, parse_computed_params_object, parse_filter_expression, parse_query_pairs,
68};
69
70pub use trusted_proxy::{ForwardedHeader, TrustedProxyConfig};