mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-13 08:22:55 +00:00
Which is mainly generational state (terms) and useful LSNs. Also add /status basic healthcheck request which is now used in tests to determine the safekeeper is up; this fixes #726. ref #115
34 lines
812 B
Rust
34 lines
812 B
Rust
use std::str::FromStr;
|
|
|
|
use super::error::ApiError;
|
|
use hyper::{Body, Request};
|
|
use routerify::ext::RequestExt;
|
|
|
|
pub fn get_request_param<'a>(
|
|
request: &'a Request<Body>,
|
|
param_name: &str,
|
|
) -> Result<&'a str, ApiError> {
|
|
match request.param(param_name) {
|
|
Some(arg) => Ok(arg),
|
|
None => {
|
|
return Err(ApiError::BadRequest(format!(
|
|
"no {} specified in path param",
|
|
param_name
|
|
)))
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn parse_request_param<T: FromStr>(
|
|
request: &Request<Body>,
|
|
param_name: &str,
|
|
) -> Result<T, ApiError> {
|
|
match get_request_param(request, param_name)?.parse() {
|
|
Ok(v) => Ok(v),
|
|
Err(_) => Err(ApiError::BadRequest(format!(
|
|
"failed to parse {}",
|
|
param_name
|
|
))),
|
|
}
|
|
}
|