pub struct MarkdownFiles { /* private fields */ }Expand description
Actix-web service that serves a directory, rendering .md files as HTML.
§Example
use actix_mark::MarkdownFiles;
let svc = MarkdownFiles::new("/docs", "./content")
.template("<html><body><markdown></body></html>");Implementations§
Source§impl MarkdownFiles
impl MarkdownFiles
Sourcepub fn new(mount_path: &str, dir: impl Into<PathBuf>) -> Self
pub fn new(mount_path: &str, dir: impl Into<PathBuf>) -> Self
Create a new MarkdownFiles service.
mount_path: the URL prefix (e.g."/docs")dir: the filesystem directory to serve from
Sourcepub fn template(self, tmpl: impl Into<String>) -> Self
pub fn template(self, tmpl: impl Into<String>) -> Self
Set the HTML template as a string.
The template must contain a <markdown> (or <markdown/>) tag which
will be replaced with the rendered HTML content.
Sourcepub fn template_file(self, path: impl AsRef<Path>) -> Result<Self>
pub fn template_file(self, path: impl AsRef<Path>) -> Result<Self>
Load the HTML template from a file.
The file is read eagerly so errors surface at startup, not at request time.
Trait Implementations§
Source§impl HttpServiceFactory for MarkdownFiles
impl HttpServiceFactory for MarkdownFiles
fn register(self, config: &mut AppService)
Auto Trait Implementations§
impl Freeze for MarkdownFiles
impl RefUnwindSafe for MarkdownFiles
impl Send for MarkdownFiles
impl Sync for MarkdownFiles
impl Unpin for MarkdownFiles
impl UnsafeUnpin for MarkdownFiles
impl UnwindSafe for MarkdownFiles
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more