Calling the Kernel from our to-do server
For our server, we must pass in the GetUserSession trait and call it within the view with the following code:
// nanoservices/to_do/networking/actix_server/
// src/api/basic_actions/create.rs
. . .
use auth_kernel::user_session::transactions::get::GetUserSession;
pub async fn create<T, X>(
token: HeaderToken,
body: Json<NewToDoItem>
) -> Result<HttpResponse, NanoServiceError>
where
T: SaveOne + GetAll,
X: GetUserSession
{
let session = X::get_user_session(
token.unique_id
).await?;
let _ = create_core::<T>(
body.into_inner(),
session.user_id
).await?;
Ok(HttpResponse::Created().json(
get_all_core::<T>(session.user_id).await?
))
}
It should not be a surprise that all the other actions in the API for the to-do server follow suit. The delete view is redefined with the code below:
// nanoservices/to_do/networking/actix_server/
// src/api/basic_actions...