catgirl-cooking/src/networking.rs

22 lines
556 B
Rust
Raw Normal View History

use crate::structures::{RecipeForm, Tag};
2022-01-24 12:52:04 +00:00
use rocket::form::Form;
2022-01-24 02:07:35 +00:00
#[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 {
2022-01-24 12:52:04 +00:00
tags_vec.push(Tag::new(i.replace(" ", "").replace("#", "")));
}
return tags_vec;
}
2022-01-24 02:07:35 +00:00
#[post("/new-recipe", data = "<recipe>")]
pub fn new_recipe(recipe: Form<RecipeForm>) -> String {
return recipe.recipe_name.to_owned();
2022-01-24 02:07:35 +00:00
}