Framework primitives
You don't have to register a constructor for every type you want to inject.
Pavex provides a few types, called framework primitives, that you can inject
without having to register a constructor for them.
The framework primitives are:
RequestHead
. The incoming request data, minus the body.RawIncomingBody
. The raw body of the incoming request.RawPathParams
. The raw path parameters extracted from the incoming request.AllowedMethods
. The HTTP methods allowed for the current request path.ConnectionInfo
. The peer address for the current connection.
They represent raw data about the underlying connection (ConnectionInfo
),
from the incoming request (RequestHead
, RawIncomingBody
)
or from the routing system (AllowedMethods
, RawPathParams
).
Convenient, but inflexible
As a design philosophy, Pavex strives to be flexible.
You should be allowed to customize the framework to your needs, without having to fight against it
or having to give up significant functionality.
In particular, you should be able to change the way a certain type is constructed, even if that
type is defined in the pavex
crate. For example, you might want to change the JSON deserializer used to parse the incoming request body
and produce a JsonBody<T>
instance.
You lose this flexibility with framework primitives: you can't customize how they are constructed.
That's why we try to keep their number to a minimum.