MCPcopy Create free account
hub / github.com/actix/examples / update

Function update

basics/todo/src/api.rs:75–90  ·  view source on GitHub ↗
(
    db: web::Data<SqlitePool>,
    params: web::Path<UpdateParams>,
    form: web::Form<UpdateForm>,
    session: Session,
)

Source from the content-addressed store, hash-verified

73}
74
75pub async fn update(
76 db: web::Data<SqlitePool>,
77 params: web::Path<UpdateParams>,
78 form: web::Form<UpdateForm>,
79 session: Session,
80) -> Result<impl Responder, Error> {
81 Ok(web::Redirect::to(match form._method.as_ref() {
82 "put" => toggle(db, params).await?,
83 "delete" => delete(db, params, session).await?,
84 unsupported_method => {
85 let msg = format!("Unsupported HTTP method: {unsupported_method}");
86 return Err(error::ErrorBadRequest(msg));
87 }
88 })
89 .using_status_code(StatusCode::FOUND))
90}
91
92async fn toggle(
93 pool: web::Data<SqlitePool>,

Callers

nothing calls this directly

Calls 2

toggleFunction · 0.85
deleteFunction · 0.85

Tested by

no test coverage detected