Improve web header performance

This commit is contained in:
Tobie Morgan Hitchcock 2022-02-09 13:55:21 +00:00
parent 8cd1cfba08
commit 007ab9efbf
2 changed files with 25 additions and 10 deletions

View file

@ -1,4 +1,12 @@
// The name and version of this build
pub const PKG_NAME: &'static str = env!("CARGO_PKG_NAME");
pub const PKG_VERS: &'static str = env!("CARGO_PKG_VERSION");
// The publicly visible name of the server
pub const SERVER_NAME: &'static str = "SurrealDB";
// The public endpoint for the database administration interface
pub const APP_ENDPOINT: &'static str = "https://app.surrealdb.com";
// Specifies how many subqueries will be processed recursively before the query fails. // Specifies how many subqueries will be processed recursively before the query fails.
pub const MAX_RECURSIVE_QUERIES: usize = 16; pub const MAX_RECURSIVE_QUERIES: usize = 16;
pub const APP_ENDPOINT: &'static str = "https://app.surrealdb.com";

View file

@ -1,13 +1,20 @@
const NAME: &'static str = env!("CARGO_PKG_NAME"); use crate::cnf::PKG_NAME;
const VERS: &'static str = env!("CARGO_PKG_VERSION"); 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 { pub fn version() -> warp::filters::reply::WithHeader {
let val = format!("{}-{}", NAME, VERS); let val = format!("{}-{}", PKG_NAME, PKG_VERS);
warp::reply::with::header("Version", val) warp::reply::with::header(VERSION, val)
} }
pub fn server() -> warp::filters::reply::WithHeader { pub fn server() -> warp::filters::reply::WithHeader {
warp::reply::with::header("Server", "SurrealDB") warp::reply::with::header(SERVER, SERVER_NAME)
} }
pub fn cors() -> warp::filters::cors::Builder { pub fn cors() -> warp::filters::cors::Builder {
@ -27,8 +34,8 @@ pub fn cors() -> warp::filters::cors::Builder {
http::header::AUTHORIZATION, http::header::AUTHORIZATION,
http::header::CONTENT_TYPE, http::header::CONTENT_TYPE,
http::header::ORIGIN, http::header::ORIGIN,
"NS".parse().unwrap(), NS.parse().unwrap(),
"DB".parse().unwrap(), DB.parse().unwrap(),
"ID".parse().unwrap(), ID.parse().unwrap(),
]) ])
} }