MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / edit_post

Function edit_post

examples/axum_example/api/src/lib.rs:148–166  ·  view source on GitHub ↗
(
    state: State<AppState>,
    Path(id): Path<i32>,
)

Source from the content-addressed store, hash-verified

146}
147
148async fn edit_post(
149 state: State<AppState>,
150 Path(id): Path<i32>,
151) -> Result<Html<String>, (StatusCode, &'static str)> {
152 let post: post::Model = QueryCore::find_post_by_id(&state.conn, id)
153 .await
154 .expect("could not find post")
155 .unwrap_or_else(|| panic!("could not find post with id {id}"));
156
157 let mut ctx = tera::Context::new();
158 ctx.insert("post", &post);
159
160 let body = state
161 .templates
162 .render("edit.html.tera", &ctx)
163 .map_err(|_| (StatusCode::INTERNAL_SERVER_ERROR, "Template error"))?;
164
165 Ok(Html(body))
166}
167
168async fn update_post(
169 state: State<AppState>,

Callers

nothing calls this directly

Calls 2

newFunction · 0.50
insertMethod · 0.45

Tested by

no test coverage detected