hashira 0.0.2-alpha

A server side rendering framework build on top of Yew
Documentation
mod any_form;
mod handler;
mod hooks;
pub mod into_request_config;

use crate::{
    app::RequestContext,
    routing::RouteMethod,
    types::BoxFuture,
    web::{Body, IntoJsonResponse},
};
pub use any_form::*;
pub use handler::*;
pub use hooks::*;

/// An action that can be execute on the server.
pub trait Action: 'static {
    /// The type of the body of the action response.
    type Response: IntoJsonResponse + 'static;

    /// The path of the route.
    fn route() -> &'static str;

    /// Returns the methods this action can be called:
    fn method() -> RouteMethod {
        RouteMethod::GET
            | RouteMethod::POST
            | RouteMethod::PUT
            | RouteMethod::PATCH
            | RouteMethod::DELETE
    }

    /// Call this action and returns a response.
    fn call(ctx: RequestContext, body: Body) -> BoxFuture<crate::Result<Self::Response>>;
}