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

Function edit

examples/salvo_example/api/src/lib.rs:85–105  ·  view source on GitHub ↗
(req: &mut Request, depot: &mut Depot)

Source from the content-addressed store, hash-verified

83
84#[handler]
85async fn edit(req: &mut Request, depot: &mut Depot) -> Result<Text<String>> {
86 let state = depot
87 .obtain::<AppState>()
88 .ok_or_else(StatusError::internal_server_error)?;
89 let conn = &state.conn;
90 let id = req.param::<i32>("id").unwrap_or_default();
91
92 let post: post::Model = Query::find_post_by_id(conn, id)
93 .await
94 .map_err(|_| StatusError::internal_server_error())?
95 .ok_or_else(StatusError::not_found)?;
96
97 let mut ctx = tera::Context::new();
98 ctx.insert("post", &post);
99
100 let body = state
101 .templates
102 .render("edit.html.tera", &ctx)
103 .map_err(|_| StatusError::internal_server_error())?;
104 Ok(Text::Html(body))
105}
106
107#[handler]
108async fn update(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Result<()> {

Callers

nothing calls this directly

Calls 2

newFunction · 0.70
insertMethod · 0.45

Tested by

no test coverage detected