use std::io::Cursor; use std::str::FromStr; use tiny_http::{Header, Response}; use crate::repo::recipe::StaticRecipeRepo; use crate::rest::types::Url; use crate::{domain, rest}; pub fn fetch_list(rest_ctx: &rest::Context, _url: &Url) -> Response>> { use domain::recipe::fetch_list; let repo = StaticRecipeRepo; let ctx = rest_ctx.clone().into(); // TODO: catch notfound error let recipe = fetch_list::execute(&repo, &ctx) .into_iter() .map(rest::Recipe::from) .collect::>(); let data = serde_json::to_string(&recipe).unwrap(); Response::from_string(data) .with_header(Header::from_str("content-type: application/json").unwrap()) }