surrealpatch/src/web/head.rs

35 lines
848 B
Rust
Raw Normal View History

2020-06-29 15:36:01 +00:00
const NAME: &'static str = env!("CARGO_PKG_NAME");
const VERS: &'static str = env!("CARGO_PKG_VERSION");
pub fn version() -> warp::filters::reply::WithHeader {
let val = format!("{}-{}", NAME, VERS);
warp::reply::with::header("Version", val)
}
2021-03-29 15:43:37 +00:00
pub fn server() -> warp::filters::reply::WithHeader {
warp::reply::with::header("Server", "SurrealDB")
2020-06-29 15:36:01 +00:00
}
pub fn cors() -> warp::filters::cors::Builder {
warp::cors()
.max_age(86400)
.allow_any_origin()
.allow_methods(vec![
http::Method::GET,
http::Method::PUT,
http::Method::POST,
http::Method::PATCH,
http::Method::DELETE,
http::Method::OPTIONS,
])
.allow_headers(vec![
http::header::ACCEPT,
http::header::AUTHORIZATION,
http::header::CONTENT_TYPE,
http::header::ORIGIN,
"NS".parse().unwrap(),
"DB".parse().unwrap(),
"ID".parse().unwrap(),
])
}