catgirl-cooking/src/networking.rs

22 lines
556 B
Rust

use crate::structures::{RecipeForm, Tag};
use rocket::form::Form;
#[get("/test")]
pub fn test() -> String {
return "Hello! :3".to_string();
}
pub fn parse_tags(tags: String) -> Vec<Tag> {
let split: Vec<&str> = tags.split(",").collect();
let mut tags_vec: Vec<Tag> = Vec::new();
for i in split {
tags_vec.push(Tag::new(i.replace(" ", "").replace("#", "")));
}
return tags_vec;
}
#[post("/new-recipe", data = "<recipe>")]
pub fn new_recipe(recipe: Form<RecipeForm>) -> String {
return recipe.recipe_name.to_owned();
}