feat: implement MessagePack codec for server functions
Some checks failed
Build MIPS Binary / build (push) Failing after 1m12s

This commit is contained in:
spinline
2026-02-11 02:01:02 +03:00
parent 40c9f66e5c
commit 6a882b75b6
3 changed files with 119 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
use leptos::prelude::*;
use serde::{Deserialize, Serialize};
use crate::codec::MessagePack;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct UserResponse {
@@ -19,7 +20,7 @@ pub struct SetupStatus {
pub completed: bool,
}
#[server(GetSetupStatus, "/api/server_fns/GetSetupStatus")]
#[server(GetSetupStatus, "/api/server_fns/GetSetupStatus", encoding = "MessagePack")]
pub async fn get_setup_status() -> Result<SetupStatus, ServerFnError> {
use crate::DbContext;
@@ -32,7 +33,7 @@ pub async fn get_setup_status() -> Result<SetupStatus, ServerFnError> {
})
}
#[server(Setup, "/api/server_fns/Setup")]
#[server(Setup, "/api/server_fns/Setup", encoding = "MessagePack")]
pub async fn setup(username: String, password: String) -> Result<(), ServerFnError> {
use crate::DbContext;
@@ -54,7 +55,7 @@ pub async fn setup(username: String, password: String) -> Result<(), ServerFnErr
Ok(())
}
#[server(Login, "/api/server_fns/Login")]
#[server(Login, "/api/server_fns/Login", encoding = "MessagePack")]
pub async fn login(username: String, password: String) -> Result<UserResponse, ServerFnError> {
use crate::DbContext;
use leptos_axum::ResponseOptions;
@@ -110,7 +111,7 @@ pub async fn login(username: String, password: String) -> Result<UserResponse, S
}
}
#[server(Logout, "/api/server_fns/Logout")]
#[server(Logout, "/api/server_fns/Logout", encoding = "MessagePack")]
pub async fn logout() -> Result<(), ServerFnError> {
use leptos_axum::ResponseOptions;
use cookie::{Cookie, SameSite};
@@ -131,7 +132,7 @@ pub async fn logout() -> Result<(), ServerFnError> {
Ok(())
}
#[server(GetUser, "/api/server_fns/GetUser")]
#[server(GetUser, "/api/server_fns/GetUser", encoding = "MessagePack")]
pub async fn get_user() -> Result<Option<UserResponse>, ServerFnError> {
use axum::http::HeaderMap;
use leptos_axum::extract;