mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-21 11:59:48 -05:00
Make overrides option
This commit is contained in:
parent
e042821848
commit
402fe18e18
2 changed files with 4 additions and 3 deletions
|
@ -74,7 +74,7 @@ pub struct PasteConfig {
|
||||||
pub delete_expired_files: Option<CleanupConfig>,
|
pub delete_expired_files: Option<CleanupConfig>,
|
||||||
/// Highlight override.
|
/// Highlight override.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub highlight_override: HashMap<String, String>,
|
pub highlight_override: Option<HashMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cleanup configuration.
|
/// Cleanup configuration.
|
||||||
|
|
|
@ -95,8 +95,9 @@ async fn serve(
|
||||||
None => "default",
|
None => "default",
|
||||||
});
|
});
|
||||||
let mime_str = mime_type.to_string();
|
let mime_str = mime_type.to_string();
|
||||||
let overrides = &config.paste.highlight_override;
|
if let Some(overrides) = &config.paste.highlight_override {
|
||||||
values.insert("type", if overrides.contains_key(&mime_str) { overrides[&mime_str].as_str() } else { "" });
|
values.insert("type", if overrides.contains_key(&mime_str) { overrides[&mime_str].as_str() } else { "" });
|
||||||
|
}
|
||||||
let rendered = tmpl.fill_in(&values);
|
let rendered = tmpl.fill_in(&values);
|
||||||
return Ok(HttpResponse::Ok().content_type(mime::TEXT_HTML).body(rendered.to_string()))
|
return Ok(HttpResponse::Ok().content_type(mime::TEXT_HTML).body(rendered.to_string()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue