Function
create_post
(
state: State<AppState>,
mut cookies: Cookies,
form: Form<post::Model>,
)
Source from the content-addressed store, hash-verified
| 127 | } |
| 128 | |
| 129 | async fn create_post( |
| 130 | state: State<AppState>, |
| 131 | mut cookies: Cookies, |
| 132 | form: Form<post::Model>, |
| 133 | ) -> Result<PostResponse, (StatusCode, &'static str)> { |
| 134 | let form = form.0; |
| 135 | |
| 136 | MutationCore::create_post(&state.conn, form) |
| 137 | .await |
| 138 | .expect("could not insert post"); |
| 139 | |
| 140 | let data = FlashData { |
| 141 | kind: "success".to_owned(), |
| 142 | message: "Post successfully added".to_owned(), |
| 143 | }; |
| 144 | |
| 145 | Ok(post_response(&mut cookies, data)) |
| 146 | } |
| 147 | |
| 148 | async fn edit_post( |
| 149 | state: State<AppState>, |