41 lines
996 B
Rust
41 lines
996 B
Rust
use crate::cnf::PKG_NAME;
|
|
use crate::cnf::PKG_VERS;
|
|
use crate::cnf::SERVER_NAME;
|
|
|
|
const ID: &'static str = "ID";
|
|
const NS: &'static str = "NS";
|
|
const DB: &'static str = "DB";
|
|
const SERVER: &'static str = "Server";
|
|
const VERSION: &'static str = "Version";
|
|
|
|
pub fn version() -> warp::filters::reply::WithHeader {
|
|
let val = format!("{}-{}", PKG_NAME, PKG_VERS);
|
|
warp::reply::with::header(VERSION, val)
|
|
}
|
|
|
|
pub fn server() -> warp::filters::reply::WithHeader {
|
|
warp::reply::with::header(SERVER, SERVER_NAME)
|
|
}
|
|
|
|
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(),
|
|
])
|
|
}
|