catgirl-cooking/src/networking.rs

25 lines
621 B
Rust
Raw Normal View History

2022-01-24 02:07:35 +00:00
use rocket::form::Form;
use crate::structures::{RecipeForm, Tag};
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 {
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
}