Trait ohkami::IntoResponse
source · pub trait IntoResponse {
// Required method
fn into_response(self) -> Response;
}
Expand description
Represents “can be handlers’ return value”.
example.rs
use ohkami::prelude::*;
struct MyResponse {
message: String,
}
impl IntoResponse for MyResponse {
fn into_response(self) -> Response {
Response::OK().with_text(self.message)
}
}
async fn handler() -> MyResponse {
MyResponse {
message: String::from("Hello!")
}
}
#[tokio::main]
async fn main() {
Ohkami::new(
"/".GET(handler)
).howl("localhost:5050").await
}