Ensure error is returned when NS/DB header are not present
This commit is contained in:
parent
2646ea119e
commit
f46acec96f
2 changed files with 14 additions and 2 deletions
|
@ -14,6 +14,12 @@ pub enum Error {
|
||||||
#[error("The request body contains invalid data")]
|
#[error("The request body contains invalid data")]
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
|
#[error("There was no NS header present in the request")]
|
||||||
|
NoNsHeader,
|
||||||
|
|
||||||
|
#[error("There was no DB header present in the request")]
|
||||||
|
NoDbHeader,
|
||||||
|
|
||||||
#[error("There was a problem with authentication")]
|
#[error("There was a problem with authentication")]
|
||||||
InvalidAuth,
|
InvalidAuth,
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,15 @@ async fn handler(session: Session) -> Result<impl warp::Reply, warp::Rejection>
|
||||||
// Get the datastore reference
|
// Get the datastore reference
|
||||||
let db = DB.get().unwrap();
|
let db = DB.get().unwrap();
|
||||||
// Extract the NS header value
|
// Extract the NS header value
|
||||||
let nsv = session.ns.clone().unwrap();
|
let nsv = match session.ns {
|
||||||
|
Some(ns) => ns,
|
||||||
|
None => return Err(warp::reject::custom(Error::NoNsHeader)),
|
||||||
|
};
|
||||||
// Extract the DB header value
|
// Extract the DB header value
|
||||||
let dbv = session.db.clone().unwrap();
|
let dbv = match session.db {
|
||||||
|
Some(db) => db,
|
||||||
|
None => return Err(warp::reject::custom(Error::NoDbHeader)),
|
||||||
|
};
|
||||||
// Create a chunked response
|
// Create a chunked response
|
||||||
let (mut chn, bdy) = Body::channel();
|
let (mut chn, bdy) = Body::channel();
|
||||||
// Create a new bounded channel
|
// Create a new bounded channel
|
||||||
|
|
Loading…
Reference in a new issue