[−][src]Struct ssr::Ssr
The main struct of the crate that manages Node.js process and handles rendering.
Implementations
impl Ssr
[src]
pub async fn new(cfg: SsrConfig) -> Result<Self, InitializationError>
[src]
Creates an Ssr
instance.
Example
let ssr = Ssr::new( SsrConfig { port: 9000, js_worker: PathBuf::from("./node_modules/ssr-rs/worker.js"), global_js_renderer: Some(PathBuf::from("./js/ssr.js")), } );
pub async fn render<D: Serialize>(
&self,
uri: &Uri,
data: &D,
js_renderer: JsRenderer
) -> Result<String, RenderingError>
[src]
&self,
uri: &Uri,
data: &D,
js_renderer: JsRenderer
) -> Result<String, RenderingError>
Renders a response to an incoming request using Node.js worker.
Example
let uri = req.uri(); let data = db::get_data(); match ssr.render(uri, &data, JsRenderer::Global).await { Ok(html) => HttpResponse::Ok().body(html), Err(error) => { error!("Error: {}", error); HttpResponse::InternalServerError().finish() } }
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Ssr
[src]
impl Send for Ssr
[src]
impl Sync for Ssr
[src]
impl Unpin for Ssr
[src]
impl !UnwindSafe for Ssr
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,