@@ -70,7 +70,7 @@ pub async fn create_dashboard(
70
70
pub async fn update_dashboard (
71
71
req : HttpRequest ,
72
72
dashboard_id : Path < String > ,
73
- Json ( dashboard) : Json < Dashboard > ,
73
+ dashboard : Option < Json < Dashboard > > ,
74
74
) -> Result < impl Responder , DashboardError > {
75
75
let user_id = get_hash ( & get_user_from_request ( & req) ?) ;
76
76
let dashboard_id = validate_dashboard_id ( dashboard_id. into_inner ( ) ) ?;
@@ -86,7 +86,10 @@ pub async fn update_dashboard(
86
86
87
87
// Validate: either query params OR body, not both
88
88
let has_query_params = !query_map. is_empty ( ) ;
89
- let has_body_update = dashboard. title != existing_dashboard. title || dashboard. tiles . is_some ( ) ;
89
+ let has_body_update = dashboard
90
+ . as_ref ( )
91
+ . map ( |d| d. title != existing_dashboard. title || d. tiles . is_some ( ) )
92
+ . unwrap_or ( false ) ;
90
93
91
94
if has_query_params && has_body_update {
92
95
return Err ( DashboardError :: Metadata (
@@ -121,6 +124,9 @@ pub async fn update_dashboard(
121
124
}
122
125
existing_dashboard
123
126
} else {
127
+ let dashboard = dashboard
128
+ . ok_or ( DashboardError :: Metadata ( "Request body is required" ) ) ?
129
+ . into_inner ( ) ;
124
130
if let Some ( tiles) = & dashboard. tiles {
125
131
if tiles. iter ( ) . any ( |tile| tile. tile_id . is_nil ( ) ) {
126
132
return Err ( DashboardError :: Metadata ( "Tile ID must be provided" ) ) ;
0 commit comments