pub trait PostgresRequestExtensions {
// Required method
fn pg_conn(
&self,
) -> Result<PooledConnection<PostgresConnectionManager>, (StatusCode, GetTimeout)>;
}
Expand description
Add pg_conn()
helper method to nickel::Request
This trait must only be used in conjunction with PostgresMiddleware
.
On error, the method returns a tuple per Nickel convention. This allows the route to use the
try_with!
macro.
Example:
ⓘ
app.get("/my_counter", middleware! { |request, response|
let db = try_with!(response, request.pg_conn());
});