From 402fe18e1847288d428d3a914a331e00fe3bd889 Mon Sep 17 00:00:00 2001 From: Dan Ponte Date: Thu, 18 May 2023 08:11:47 -0400 Subject: [PATCH] Make overrides option --- src/config.rs | 2 +- src/server.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index ea06918..d0c12bf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -74,7 +74,7 @@ pub struct PasteConfig { pub delete_expired_files: Option, /// Highlight override. #[serde(default)] - pub highlight_override: HashMap, + pub highlight_override: Option>, } /// Cleanup configuration. diff --git a/src/server.rs b/src/server.rs index 8085d8f..fb5d329 100644 --- a/src/server.rs +++ b/src/server.rs @@ -95,8 +95,9 @@ async fn serve( None => "default", }); let mime_str = mime_type.to_string(); - let overrides = &config.paste.highlight_override; - values.insert("type", if overrides.contains_key(&mime_str) { overrides[&mime_str].as_str() } else { "" }); + if let Some(overrides) = &config.paste.highlight_override { + values.insert("type", if overrides.contains_key(&mime_str) { overrides[&mime_str].as_str() } else { "" }); + } let rendered = tmpl.fill_in(&values); return Ok(HttpResponse::Ok().content_type(mime::TEXT_HTML).body(rendered.to_string())) }