async fn create(
    db: Data<PgPool>,
    auth: TokenUser,
    parent: Path<JigId>,
    req: Json<<module::Create as ApiEndpoint>::Req>,
) -> Result<HttpResponse, error::Auth> {
    let parent_id = parent.into_inner();

    db::jig::authz(&*db, auth.0.user_id, Some(parent_id)).await?;

    let req = req.into_inner();

    let (id, _index) = db::jig::module::create(&*db, parent_id, req.body).await?;

    Ok(HttpResponse::Created().json(CreateResponse { id }))
}
/// Create a new module on a draft JIG.
Create a new module on a draft JIG.
Create a new module on a draft JIG .
async fn create(
    db: Data<PgPool>,
    auth: TokenUser,
    parent: Path<JigId>,
    req: Json<<module::Create as ApiEndpoint>::Req>,
) -> Result<HttpResponse, error::Auth> {
    let parent_id = parent.into_inner();
    db::jig::authz(&*db, auth.0.user_id, Some(parent_id)).await?;
    let req = req.into_inner();
    let (id, _index) = db::jig::module::create(&*db, parent_id, req.body).await?;
    Ok(HttpResponse::Created().json(CreateResponse { id }))
}
async fn create ( db : Data < PgPool > , auth : TokenUser , parent : Path < JigId > , req : Json < < module :: Create as ApiEndpoint > :: Req > , ) -> Result < HttpResponse , error :: Auth > { let parent_id = parent . into_inner ( ) ; db :: jig :: authz ( & * db , auth . 0 . user_id , Some ( parent_id ) ) . await ? ; let req = req . into_inner ( ) ; let ( id , _index ) = db :: jig :: module :: create ( & * db , parent_id , req . body ) . await ? ; Ok ( HttpResponse :: Created ( ) . json ( CreateResponse { id } ) ) }
Create a new module on a draft JIG.
Create a new module on a draft JIG .
db
Data<PgPool>
auth
TokenUser
parent
Path<JigId>
req
Json<<module::Create as ApiEndpoint>::Req>
db
Data<PgPool>
auth
TokenUser
parent
Path<JigId>
req
Json<<module::Create as ApiEndpoint>::Req>