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

Function create

basics/todo/src/api.rs:46–63  ·  view source on GitHub ↗
(
    params: web::Form<CreateForm>,
    pool: web::Data<SqlitePool>,
    session: Session,
)

Source from the content-addressed store, hash-verified

44}
45
46pub async fn create(
47 params: web::Form<CreateForm>,
48 pool: web::Data<SqlitePool>,
49 session: Session,
50) -> Result<impl Responder, Error> {
51 if params.description.is_empty() {
52 session::set_flash(&session, FlashMessage::error("Description cannot be empty"))?;
53 Ok(web::Redirect::to("/").using_status_code(StatusCode::FOUND))
54 } else {
55 db::create_task(params.into_inner().description, &pool)
56 .await
57 .map_err(error::ErrorInternalServerError)?;
58
59 session::set_flash(&session, FlashMessage::success("Task successfully added"))?;
60
61 Ok(web::Redirect::to("/").using_status_code(StatusCode::FOUND))
62 }
63}
64
65#[derive(Debug, Deserialize)]
66pub struct UpdateParams {

Callers 5

bytes_to_payloadFunction · 0.85
bytes_to_payloadFunction · 0.85
mainFunction · 0.85
tcp_serverFunction · 0.85
save_file_manualFunction · 0.85

Calls 3

set_flashFunction · 0.85
create_taskFunction · 0.85
successFunction · 0.85

Tested by

no test coverage detected