mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2026-09-26 20:41:45 +00:00
test: add shared api client tests and remove dead backend code
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
use axum::{body::Body, extract::Request, http::HeaderValue, middleware::Next, response::Response};
|
||||
|
||||
const CUSTOM_HEADER_NAME: &str = "Content-Security-Policy";
|
||||
const CUSTOM_HEADER_VALUE: &str = "default-src 'self'; script-src 'report-sample' 'self'; style-src 'report-sample' 'self'; object-src 'none'; base-uri 'self'; connect-src 'self' data:; font-src 'self'; frame-src 'self'; img-src 'self'; manifest-src 'self'; media-src 'self'; worker-src 'none';";
|
||||
|
||||
lazy_static! {
|
||||
static ref HEADER_VALUE: HeaderValue = HeaderValue::from_static(CUSTOM_HEADER_VALUE);
|
||||
}
|
||||
|
||||
pub async fn add_csp_header(request: Request<Body>, next: Next) -> Response {
|
||||
let mut response = next.run(request).await;
|
||||
response
|
||||
.headers_mut()
|
||||
.append(CUSTOM_HEADER_NAME, HEADER_VALUE.clone());
|
||||
response
|
||||
}
|
||||
@@ -15,7 +15,6 @@ use tower_http::{
|
||||
extern crate lazy_static;
|
||||
|
||||
mod config;
|
||||
mod csp;
|
||||
mod health;
|
||||
mod note;
|
||||
mod status;
|
||||
|
||||
@@ -68,13 +68,6 @@ pub fn get_data(id: &str) -> Result<Option<Vec<u8>>, &'static str> {
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
pub fn has_views(id: &str) -> Result<bool, &'static str> {
|
||||
let key = prefixed(id);
|
||||
let mut c = conn()?;
|
||||
let has: bool = c.hexists::<_, _, bool>(&key, "views").map_err(|_| "Cache error")?;
|
||||
Ok(has)
|
||||
}
|
||||
|
||||
pub fn decrement_views(id: &str) -> Result<i64, &'static str> {
|
||||
let key = prefixed(id);
|
||||
let mut c = conn()?;
|
||||
|
||||
Reference in New Issue
Block a user